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

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

实现效果

代码截图

相关代码

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>
相关推荐
程序员爱钓鱼5 分钟前
Go语言泛型-泛型约束与实践
前端·后端·go
丰锋ff5 分钟前
计网学习笔记第2章 物理层(灰灰题库)
笔记·学习
前端小巷子6 分钟前
web从输入网址到页面加载完成
前端·面试·浏览器
江城开朗的豌豆7 分钟前
Vue路由动态生成秘籍:让你的链接'活'起来!
前端·javascript·vue.js
晓得迷路了7 分钟前
栗子前端技术周刊第 88 期 - Apache ECharts 6.0 beta、Deno 2.4、Astro 5.11...
前端·javascript·echarts
江城开朗的豌豆13 分钟前
在写vue公用组件的时候,怎么提高可配置性
前端·javascript·vue.js
江城开朗的豌豆13 分钟前
Vue路由跳转的N种姿势,总有一种适合你!
前端·javascript·vue.js
江城开朗的豌豆14 分钟前
Vue路由玩法大揭秘:三种路由模式你Pick谁?
前端·javascript·vue.js
江城开朗的豌豆15 分钟前
Vue路由守卫全攻略:给页面访问装上'安检门'
前端·javascript·vue.js
小磊哥er21 分钟前
【前端工程化】前端组件模版构建那些事
前端