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

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

实现效果

代码截图

相关代码

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>
相关推荐
无责任此方_修行中4 分钟前
一行代码的“法律陷阱”:开发者必须了解的开源许可证知识
前端·后端·开源
wdfk_prog16 分钟前
[Linux]学习笔记系列 -- [kernel]kallsyms
linux·笔记·学习
合作小小程序员小小店23 分钟前
web网页开发,在线物流管理系统,基于Idea,html,css,jQuery,jsp,java,SSM,mysql
java·前端·后端·spring·intellij-idea·web
Elnaij37 分钟前
从C++开始的编程生活(12)——vector简单介绍和迭代器
开发语言·c++
GISer_Jing1 小时前
OSG底层从Texture读取Image实现:readImageFromCurrentTexture
前端·c++·3d
饼干,1 小时前
第23天python内容
开发语言·python
!chen1 小时前
CPP 学习笔记 语法总结
c++·笔记·学习
数学难1 小时前
Java面试题2:Java线程池原理
java·开发语言
Charles_go1 小时前
C#8、有哪些访问修饰符
java·前端·c#
慧一居士1 小时前
Vue中 class 和 style 属性的区别对比
前端·vue.js