Blogger Information
Blog 29
fans 0
comment 0
visits 19813
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
定位类型、模态框
手机用户1576673622
Original
678 people have browsed it

定位类型

  1. 静态定位: position: static 默认,也就是文档流定位,元素的显示位置与源码顺序一致(不是定位元素)
  2. 相对定位: position: relative;相对于该元素在文档流中的原始位置进行偏移
  3. 绝对定位: position: absolue;相对于它的祖先中离它最近的”定位元素”的位置发生偏移(如果祖先元素中不存在定位元素,它就参考根元素(html)进行定位)
  4. 固定定位: position: fixed; 是绝对定位的一个特例,它始终相对于html定位
  • 定位元素:只要这个元素中有position: relative;或者 position:absolute;就称为定位元素

    模态框

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>模态框</title>
    8. <link rel="stylesheet" href="style1.css">
    9. </head>
    10. <body>
    11. <!-- 页眉 -->
    12. <header>
    13. <h2>百度一下</h2>
    14. <button>登录</button>
    15. </header>
    16. <!-- 模态框 -->
    17. <div class="modal">
    18. <!-- 蒙板。用来盖住后面的内容,使其透明化 -->
    19. <div class="modal-backdrop"></div>
    20. <div class="modal-body">
    21. <button class="close">关闭</button>
    22. <form action="" method="POST">
    23. <table>
    24. <caption>用户登录</caption>
    25. <tr>
    26. <td><label for="name">用户名:</label></td>
    27. <td><input type="name" name="name" id="name"></td>
    28. </tr>
    29. <tr>
    30. <td><label for="password">密码:</label></td>
    31. <td><input type="password" name="password" id="password"></td>
    32. </tr>
    33. <tr>
    34. <td><button>登录</button></td>
    35. </tr>
    36. </table>
    37. </form>
    38. </div>
    39. </div>
    40. </body>
    41. </html>

    css

    1. *{
    2. margin: 0;
    3. padding: 0;
    4. box-sizing: border-box;
    5. }
    6. header {
    7. background-color: #ccc;
    8. margin: 0.5em 1em;
    9. overflow: hidden;
    10. }
    11. header h2 {
    12. float: left;
    13. }
    14. header button {
    15. float:right;
    16. width: 10em;
    17. height: 2.5em;
    18. }
    19. header button:hover{
    20. cursor: pointer;
    21. background-color: #fff;
    22. }
    23. /* 模态框 */
    24. /* 蒙板 */
    25. .modal .modal-backdrop{
    26. background-color: rgb( 0,0,0,0.5);
    27. position: fixed;
    28. top: 0;
    29. left: 0;
    30. right: 0;
    31. bottom: 0;
    32. }
    33. /* 主体 */
    34. .modal .modal-body{
    35. padding: 1em;
    36. min-width: 20em;
    37. border: 1px solid #ccc;
    38. background: linear-gradient(to right, lightcyan, #fff);
    39. /* 固定定位 */
    40. position: fixed;
    41. top: 5em;
    42. right: 20em;
    43. left: 20em;
    44. }
    45. /* 页面初始化时,模态框应该隐藏 */
    46. /* .modal {
    47. display: none;
    48. } */
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post