好看的原创弹窗公告代码分享


代码用文档方式给大家,直接插入到你们网站里面就行了,PC端和移动端都适用有点基础的可以改下代码让他更好看!
代码如下:

  1. <div class="web_notice" style="
  2. position: fixed;
  3. top: 0;
  4. left: 0;
  5. width: 100%;
  6. height: 100%;
  7. background: rgba(0,0,0,0.3);
  8. z-index: 99999;
  9. ">
  10. <div style="
  11. position: fixed;
  12. top: 50%;
  13. left: 50%;
  14. width: 550px;
  15. background: #FFF;
  16. transform: translate(-50%, -50%);
  17. border-radius: 40px;
  18. padding: 50px 40px;
  19. ">
  20. <h3 style="
  21. font-weight: bold;
  22. text-align: center;
  23. font-size: 30px;
  24. ">网站通知</h3>
  25. <div style="
  26. font-size: 16px;
  27. margin-top: 26px;
  28. line-height: 30px;
  29. color: #999;
  30. ">公告</div><a style="
  31. display: block;
  32. background: #98a3ff;
  33. color: #FFF;
  34. text-align: center;
  35. font-weight: bold;
  36. font-size: 19px;
  37. line-height: 60px;
  38. margin: 0 auto;
  39. margin-top: 45px;
  40. border-radius: 32px;
  41. width: 80%;
  42. " οnclick="javascript:document.querySelector('.web_notice').remove()">我知道了</ a>
  43. </div>
  44. </div>

 

  • 4
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 8
    评论
以下是一些美化alert的CSS代码: ``` /* Alert样式 */ .alert { padding: 20px; background-color: #f44336; color: white; border-radius: 5px; } /* 成功 Alert样式 */ .alert.success {background-color: #4CAF50;} /* 信息 Alert样式 */ .alert.info {background-color: #2196F3;} /* 警告 Alert样式 */ .alert.warning {background-color: #ff9800;} /* 关闭按钮样式 */ .closebtn { margin-left: 15px; color: white; font-weight: bold; float: right; font-size: 22px; line-height: 20px; cursor: pointer; transition: 0.3s; } /* 鼠标悬停关闭按钮样式 */ .closebtn:hover { color: black; } ``` 以下是一个基于JavaScript的alert美化示例: ``` function showAlert(message, type) { // 创建一个alert元素 var alertElement = document.createElement("div"); // 添加样式类 alertElement.classList.add("alert"); if (type == "success") { alertElement.classList.add("success"); } else if (type == "info") { alertElement.classList.add("info"); } else if (type == "warning") { alertElement.classList.add("warning"); } // 添加关闭按钮 var closeBtn = document.createElement("span"); closeBtn.classList.add("closebtn"); closeBtn.innerHTML = "×"; alertElement.appendChild(closeBtn); // 添加消息 var messageElement = document.createElement("p"); messageElement.innerHTML = message; alertElement.appendChild(messageElement); // 将alert元素添加到body中 document.body.appendChild(alertElement); // 点击关闭按钮时,删除alert元素 closeBtn.onclick = function() { alertElement.remove(); } // 5秒后自动删除alert元素 setTimeout(function() { alertElement.remove(); }, 5000); } ``` 这个函数接收两个参数:消息内容和消息类型(可选)。根据消息类型不同,alert的样式会有所不同。调用这个函数时,会创建一个alert元素,并添加到页面中。5秒后,这个alert元素会自动删除。用户也可以手动点击关闭按钮来删除这个alert元素。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

希希分享

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值