CSS美化留言板案例

CSS美化留言板案例

一.CSS美化留言板

1.输出结果

2.代码部分<!DOCTYPE html><htmllang=“zh-CN”><head><metacharset=“UTF-8”><metahttp-equiv=“X-UA-Compatible”content=“IE=edge”><metaname=“viewport”content=“width=device-width, initial-scale=1.0”><title>CSS美化留言板</title><style>*{ margin:0; padding:0; boxsizing: borderbox;} body {background小白轻松搭建系统点我wcqh.cncolor: lightblue; maxheight:1120em; maxwidth:1170px; margin:0auto; padding:030px;} h3 { margin:20px10px; textalign: center;} input { display: block; width:100%; minheight:200px; marginbottom:20px; padding:5px10px250px;}.list > li { display: flex; placecontent: spacebetween; backgroundcolor: lightcoral; lineheight:36p小白轻松搭建系统点我wcqh.cnx; marginbottom:5px; borderradius:3px; padding:010px;}.list > li > button { borderradius:5px; margin:5px0; border:1px; width:40px;}</style></head><body><h3>留言板</h3><inputtype=“text”onkeydown=insertComment(this)placeholder=“请输入您的留言”autofocus/><ulclass=“list”></ul></body><script>const insertComment =function(e小白轻松搭建系统点我wcqh.cnle){if(event.key ===Enter){// 1. 非空判断 event指事件对象if(ele.value.length ===0){ alert(留言不能为空)// 重置焦点 ele.focus();// 直接返回returnfalse;}// 2. 添加留言const ul = document.querySelector(.list); ele.value +=`<button onclick=“del(this.parentNode)”>删除</button>`; ul.insertAdjacentHTML(afterbegin,`<li>${ele.value}</li>`);// 3. 小白轻松搭建系统点我wcqh.cn清空输入框 ele.value =null;}};// 删除const del =function(ele){return confirm(是否删除?)?(ele.outerHTML =null):false;};</script></html>
批改老师:PHPz 批改状态:合格 老师批语:完成的很好, 效果很棒, 继续加油
作者最新博文
2022-10-15 17:06:57

© 版权声明
THE END
喜欢就支持一下吧
点赞787 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容