实现的一个网页版的简易表白墙

实现的一个网页版的表白墙

实现效果

代码截图

相关代码

javascript 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="container">
        <h1>表白墙</h1>
        <P>输入相关信息,点击提交后将会展示在表格中</P>
        <div class="div1">
            <span>谁:</span><input type="text" class="edit">
        </div>
        <div class="div1">
            <span>对谁:</span><input type="text" class="edit">
        </div>
        <div class="div1">
            <span>说:</span><input type="text" class="edit">
        </div>
        <div class="div1">
            <input type="button" value="提交" class="submit" onclick="Submit()">
        </div>
    </div>
</body>
<style>
    * {
        margin: 0px;
        padding: 0px;
    }
    .container {
        width: 400px;
        margin: 0 auto;
    }
    h1 {
        text-align: center;
        margin-bottom: 20px;
        margin-top: 40px;
    }
    p {
        text-align: center;
        color: gray;
        line-height: 63px;
    }
    .div1 {
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .edit {
        margin-bottom: 20px;
        width: 200px;
        height: 30px;
    }
    span {
        width: 50px;
        margin-bottom: 20px;
    }
    .submit {
        background-color: rgb(255, 136, 0);
        color: white;
        width: 254px;
        height: 40px;
        border: none;
        border-radius: 5px;
    }
    .submit:active {
        background-color: gray;
    }

</style>
<script>
    function Submit() {
        let edits = document.querySelectorAll('.edit')
        let from  = edits[0].value
        let to  = edits[1].value
        let message = edits[2].value
        if(from == "" || to == "" || message == "") {
            return
        }
        let div = document.createElement('div')
        div.className = 'div1'
        div.innerHTML =   from + " 对 " + to + "说:" + message 
        let container = document.querySelector('.container')
        container.appendChild(div)
        for(i = 0; i < edits.length; i++) {
            edits[i].value = "";
        }
}
</script>
</html>
相关推荐
MSTcheng.9 分钟前
【C++】C++11新特性(二)
java·开发语言·c++·c++11
晓131311 分钟前
第七章 【C语言篇:文件】 文件全面解析
linux·c语言·开发语言
愚者游世11 分钟前
Delegating Constructor(委托构造函数)各版本异同
开发语言·c++·程序人生·面试·改行学it
梵刹古音14 分钟前
【C语言】 指针基础与定义
c语言·开发语言·算法
ZH154558913115 分钟前
Flutter for OpenHarmony Python学习助手实战:Web开发框架应用的实现
python·学习·flutter
Ekehlaft17 分钟前
这款国产 AI,让 Python 小白也能玩转编程
开发语言·人工智能·python·ai·aipy
rit843249919 分钟前
MATLAB中Teager能量算子提取与解调信号的实现
开发语言·matlab
开源技术22 分钟前
Python GeoPandas基础知识:地图、投影和空间连接
开发语言·ide·python
hedley(●'◡'●)25 分钟前
基于cesium和vue的大疆司空模仿程序
前端·javascript·vue.js·python·typescript·无人机
Cult Of25 分钟前
Alicea Wind的个人网站开发日志(2)
开发语言·python·vue