模态框的实例演示

实现效果

模态框1
模态框2

关键代码

html

  1. <header>
  2. <h1 class="title">XXX信息管理系统</h1>
  3. <button onclick="showModal()">关于</button>
  4. </header>
  5. <div class="modal">
  6. <div class="modal-background" onclick="closeModal()"></div>
  7. <div class="modal-about">
  8. <h2 class="ma-title">关于</h2>
  9. <div class="content">
  10. <p>系统版本号:V1.0</p>
  11. <p>公司:XXX信息管理公司</p>
  12. <p>
  13. 公司网址:
  14. <a href="https://baidu.com" target="_blank">https://baidu.com</a>
  15. </p>
  16. <p>售后电话:XXX-XXX-XXX</p>
  17. </div>
  18. </div>
  19. </div>

css

  1. /* 样式初始化 */
  2. * {
  3. padding: 0;
  4. margin: 0;
  5. box-sizing: border-box;
  6. }
  7. /* 头部样式 */
  8. header {
  9. display: flex;
  10. background-color: cornflowerblue;
  11. padding: 0.5rem 1rem;
  12. }
  13. header > h1.title {
  14. font-size: 1rem;
  15. font-weight: normal;
  16. font-style: oblique;
  17. color: aliceblue;
  18. letter-spacing: 0.1rem;
  19. text-shadow: 1px 1px 2px #000;
  20. }
  21. header > button {
  22. margin-left: auto;
  23. width: 3rem;
  24. border: none;
  25. border-radius: 0.3rem;
  26. background-color: aliceblue;
  27. }
  28. /* 选择鼠标移到button上的样式 */
  29. header > button:hover {
  30. /* 光标属性,move,text,wait,help */
  31. cursor: pointer;
  32. margin-left: auto;
  33. width: 3rem;
  34. border: none;
  35. color: aliceblue;
  36. border-radius: 0.3rem;
  37. background-color: darkseagreen;
  38. box-shadow: 0 0 10px #fff;
  39. }
  40. /* 模态框样式 */
  41. .modal .modal-about {
  42. border: 1px solid #fff;
  43. width: 15rem;
  44. box-shadow: 5px 5px 10px #000;
  45. }
  46. .modal .modal-about > h2 {
  47. font-size: 1.25rem;
  48. background-color: cornflowerblue;
  49. color: aliceblue;
  50. padding: 0.5rem 1rem;
  51. }
  52. .modal .content {
  53. background-color: aliceblue;
  54. padding: 0.5rem 1rem;
  55. font-weight: lighter;
  56. }
  57. /* 遮罩 */
  58. .modal .modal-background {
  59. position: fixed;
  60. top: 0;
  61. right: 0;
  62. bottom: 0;
  63. left: 0;
  64. background-color: rgb(0, 0, 0, 0.5);
  65. }
  66. /* 定位 */
  67. .modal .modal-about {
  68. position: fixed;
  69. top: 30vh;
  70. left: 50%;
  71. right: 50%;
  72. /* 水平居中垂直 */
  73. transform: translate(-50%, -50%);
  74. }
  75. .modal {
  76. display: none;
  77. }

更多相关文章

  1. Cordova插件调用Android原生Activity修改其样式及背景
  2. 简单的登陆表单、后台框架、元素样式来源与优先级
  3. 选择器知识汇总
  4. 登录表单与简易框架与css元素理解
  5. HTML学习
  6. 登录表单、后台架构、样式来源与优先级
  7. 表单+简单后台架构+元素样式来源与优先级
  8. 样式来源优先级
  9. 表单、内联框架以及CSS基础学习小结

随机推荐

  1. linux获取网线插拔状态的实现
  2. Mac OSX ipfw 防火墙配置-封端口
  3. 在fc8安装TP-Linux WN3210G+USB无线网卡,
  4. 都能看懂的嵌入式linux/android alsa_apl
  5. 鸟哥linux私房菜笔记--vi
  6. linux测试硬盘读写速度
  7. 获取Perl重命名实用程序而不是内置重命名
  8. 进程实际内存占用: 私有驻留内存数(Priva
  9. 移植MT7601U AP Linux 驱动至Orangepi-PC
  10. mongodb在linux服务器上的安装和部分基础