经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » HTML/CSS » HTML » 查看文章
html实现弹窗的实例
来源:jb51  时间:2021/6/15 9:23:59  对本文有异议

上午闲来无事,用html及原生js写个弹窗,供参考。

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title></title>
  6. <style type="text/css">
  7. body{
  8. margin: 0px;
  9. }
  10. .zhezhao{
  11. position: fixed;
  12. left: 0px;
  13. top: 0px;
  14. background: #000;
  15. width: 100%;
  16. height: 100%;
  17. opacity: 0.5;
  18. }
  19. .tankuang{
  20. position: relative;
  21. background: #fff;
  22. width: 50%;
  23. height: 80%;
  24. border-radius: 5px;
  25. margin: 5% auto;
  26. }
  27. #header{
  28. height: 40px;
  29. }
  30. #header-right{
  31. position: absolute;
  32. width: 25px;
  33. height: 25px;
  34. border-radius: 5px;
  35. background: red;
  36. color: #fff;
  37. right: 5px;
  38. top: 5px;
  39. text-align: center;
  40. }
  41. </style>
  42. </head>
  43. <body>
  44. <button type="button" onclick="dianwo()">点我</button>
  45. <div class="zhezhao" id='zhezhao'>
  46. <div class="tankuang">
  47. <div id="header">
  48. <span>我是弹窗</span>
  49. <div id="header-right" onclick="hidder()">x</div>
  50. </div>
  51. </div>
  52. </div>
  53. <script type="text/javascript">
  54. document.getElementById('zhezhao').style.display="none";
  55. function dianwo(){
  56. document.getElementById('zhezhao').style.display="";
  57. }
  58. function hidder(){
  59. document.getElementById('zhezhao').style.display="none";
  60. }
  61. </script>
  62. </body>
  63. </html>

到此这篇关于html实现弹窗的实例的文章就介绍到这了,更多相关html弹窗内容请搜索w3xue以前的文章或继续浏览下面的相关文章,希望大家以后多多支持w3xue!

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号