案例-表白墙简单实现

文章目录

效果展示

初始画面

提交内容后画面(按键按下)

代码区

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表白墙</title>
</head>
<style>
    * {
        margin: 0px;
        padding: 0px;
    }
    .total {
        width: 400px;
        margin: 0px auto; /*上下、左右*/
    }
    h1 {
        text-align: center;
        padding-bottom: 30px;
    }
    p {
        text-align: center;
        color: gray;
    }
    .div1 {
        display: flex;
        justify-content: center; /*水平方向*/
        align-items: center; /*垂直方向*/
        padding-top: 5px;
    }
    span {
        width: 80px;
        height: 30px;
    }
    #edit {
        width: 200px;
        height: 30px;
    }
    .submit {
        width: 280px;
        height: 30px;
        background-color: rgba(248, 236, 7, 0.942);
        border: none;
        border-radius: 5px;
    }
    .submit:active{
        background-color: grey;
    }
</style>
<body>
    <div class="total">
        <h1>表白墙</h1>
        <p>输入后请点击提交,会将信息显示在表格中</p>
        <div class="div1">
            <span>谁:</span><input id="edit" class="who" type="text">
        </div>
        <div class="div1">
            <span>对谁:</span><input id="edit" class="ofwho" type="text">
        </div>
        <div class="div1">
            <span>说什么</span><input id="edit" class="what" type="text">
        </div>
        <div class="div1">
            <input class="submit" type="button" value="提交" onclick="submit()">
        </div>
    </div>
</body>
<script>
    function submit(){
        let containDiv = document.querySelectorAll('#edit')
        console.dir(containDiv)
        let from = containDiv[0].value
        let to = containDiv[1].value
        let message = containDiv[2].value
        console.log(from+'对'+to+'说'+message)
        // 创建div
        let nodeDiv = document.createElement('div')
        nodeDiv.className = 'div1'
        nodeDiv.innerHTML = from+'对'+to+'说'+message
        console.log(nodeDiv)
        // 尾插div
        let nodeparent = document.querySelector('.total')
        nodeparent.appendChild(nodeDiv)
    }
</script>
</html>
相关推荐
AlienZHOU3 小时前
AI Coding 时代下,我的技术面试实践分享
前端·后端·面试
Captaincc6 小时前
AI用量v0.1.11更新发布 新增 jusage doctor 诊断指令 托盘展示token 和余额 新增 AutoClaw 支持
前端·后端·vibecoding
计算机魔术师8 小时前
德国Wiki被黑后两周,OpenAI终于把模型失控的账本摊开了
前端
kyriewen8 小时前
我让 AI 当面试官面了我一轮:第 3 个追问我就卡住了(附 10 道追问清单)
前端·面试·ai编程
IT_陈寒8 小时前
Python的GIL把我坑惨了,多线程跑得比单线程还慢
前端·人工智能·后端
前端snow9 小时前
ai agent --- 多agent框架之图编排引擎-langgraph
前端
竹林8189 小时前
OmniPic Studio v3.2.1 核心技术架构与全平台发版解析文档
前端·浏览器
JamesZhang800789 小时前
页面内存只涨不跌? 一次泄漏排查, 牵出 WeakMap 的诞生
前端
Z小明9 小时前
第 6 章 组件进阶
前端·vue.js
江华森9 小时前
HTTP请求的完整过程详解:从DNS解析到TCP挥手的微秒级实战分析
前端