Blogger Information
Blog 15
fans 0
comment 0
visits 9220
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
1221 浮动与定位
fanyigle_php
Original
518 people have browsed it
  1. 浮动练习

    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. <title>浮动</title>
    7. <style>
    8. /* 清除空气*/
    9. * {
    10. margin: 0;
    11. padding: 0;
    12. box-sizing: border-box;
    13. }
    14. .box {
    15. padding: 0.5em;
    16. border: 1px solid red;
    17. float: left;
    18. }
    19. .box img {
    20. float: left;
    21. margin-right: 0.5em;
    22. border-radius: 0.2em;
    23. width: 300px;
    24. }
    25. .box .desc {
    26. overflow: hidden;
    27. }
    28. /*附加元素 */
    29. /* .box .plus {
    30. clear: both;
    31. } */
    32. /*伪元素*/
    33. /* .box::after {
    34. content: "";
    35. display: block;
    36. clear: both;
    37. } */
    38. </style>
    39. </head>
    40. <body>
    41. <!--
    42. 一父两子
    43. 1.图片浮动在左
    44. 2.图片高度被父元素察觉到:
    45. 父元素尾部附加元素或伪元素clear;
    46. 父元素自己bfc overflow:hidden;
    47. 3.描述区相对独立,文字不插脚:自己bfc overflow
    48. -->
    49. <div class="box">
    50. <img
    51. src="https://img.php.cn/upload/course/000/000/001/5fae4f08a043a576.png"
    52. alt=""
    53. />
    54. <div class="desc">
    55. <h2>第十四期_前端开发</h2>
    56. <p>
    57. php中文网第十四期前端开发部分学习目标:1、HTML5+CSS3基础知识与实战;
    58. 2、完成网站所有静态页面布局;重点:弹性布局与网格布局;3.JavaScript、jQuery、ES6基础与实战
    59. ;4.Vue.js基础与实战
    60. </p>
    61. <a href="php.cn">练一练</a>
    62. </div>
    63. <!-- <div class="plus"></div> -->
    64. </div>
    65. </body>
    66. </html>
  2. 定位练习

    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. <title>定位</title>
    7. <style>
    8. /*初始化*/
    9. * {
    10. margin: 0;
    11. padding: 0;
    12. box-sizing: border-box;
    13. }
    14. /*元素的定位默认为position:static,跟随文档流*/
    15. .box {
    16. border: 1px solid black;
    17. width: 20em;
    18. height: 14em;
    19. }
    20. /*1.在不破坏文档流的情况下,相对文档中的原始位置产生位移,后续元素保持原来的位置 */
    21. .box h2 {
    22. border: 1px solid red;
    23. background-color: antiquewhite;
    24. position: relative;
    25. top: 2em;
    26. left: 3em;
    27. }
    28. /*2.把当前元素从文档流中拎出来,相对于修改了定位属性的父祖辈元素(若无,则html),单独放置*/
    29. .box {
    30. position: relative;
    31. }
    32. .box h2 {
    33. position: absolute;
    34. }
    35. /*3.在父祖辈元素中直接以html为基础进行定位*/
    36. .box h2 {
    37. position: fixed;
    38. }
    39. /*上下左右都为0,撑满定位空间,然后一直悬在html中央*/
    40. .box h2 {
    41. top: 0;
    42. right: 0;
    43. bottom: 0;
    44. left: 0;
    45. width: 7em;
    46. height: 3em;
    47. margin: auto;
    48. }
    49. </style>
    50. </head>
    51. <body>
    52. <div class="box">
    53. <h2>php中文网</h2>
    54. <p>php中文网第14期课程现在学到了第1221部分,进度不好控制lol</p>
    55. </div>
    56. </body>
    57. </html>
  3. 模态框

    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. <title>模态框</title>
    7. <style>
    8. /* 初始化 */
    9. * {
    10. margin: 0;
    11. padding: 0;
    12. box-sizing: border-box;
    13. }
    14. /* 页眉 */
    15. header {
    16. background-color: aliceblue;
    17. padding: 0.5em;
    18. display: flow-root;
    19. }
    20. header h2 {
    21. float: left;
    22. }
    23. header button {
    24. float: right;
    25. width: 4em;
    26. height: 2em;
    27. }
    28. /* 蒙板 */
    29. .modal-mask {
    30. background: rgba(0, 0, 0, 0.3);
    31. position: fixed;
    32. top: 0;
    33. right: 0;
    34. bottom: 0;
    35. left: 0;
    36. }
    37. /* 表单 */
    38. .modal-login {
    39. padding: 0.5em;
    40. background: linear-gradient(red, blue);
    41. border: 1px solid black;
    42. min-width: 10em;
    43. /* min-width: 8em; */
    44. /* min-height: 3em; */
    45. position: fixed;
    46. top: 5em;
    47. left: 5em;
    48. right: 5em;
    49. }
    50. /* 页面载入时模态框默认隐藏*/
    51. .modal {
    52. /* display: none; */
    53. }
    54. </style>
    55. </head>
    56. <body>
    57. <!-- 页眉 -->
    58. <header>
    59. <h2>一个博客</h2>
    60. <button>登录</button>
    61. </header>
    62. <!--模态框-->
    63. <div class="modal">
    64. <!--蒙板-->
    65. <div class="modal-mask"></div>
    66. <!--登录框-->
    67. <div class="modal-login">
    68. <button class="close">关闭</button>
    69. <form action="" method="POST">
    70. <table>
    71. <caption>
    72. 用户登录
    73. </caption>
    74. <tr>
    75. <td><label for="email">邮箱:</label></td>
    76. <td><input type="email" name="email" id="email" /></td>
    77. </tr>
    78. <tr>
    79. <td><label for="password">密码:</label></td>
    80. <td><input type="password" name="password" id="password" /></td>
    81. </tr>
    82. <tr>
    83. <td></td>
    84. <td><button>登录</button></td>
    85. </tr>
    86. </table>
    87. </form>
    88. </div>
    89. </div>
    90. </body>
    91. </html>
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