Blogger Information
Blog 7
fans 0
comment 0
visits 4541
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
box-sizing和定位
辰辰
Original
519 people have browsed it

box-sizing

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. /* padding和border计算在width,height里 */
  13. box-sizing: border-box;
  14. }
  15. html {
  16. font-size: 10px;
  17. }
  18. .box {
  19. width: 20rem;
  20. height: 20rem;
  21. border: #000 solid 2px;
  22. background-color: lightblue;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <div class="box">box</div>
  28. </body>
  29. </html>

定位

  • 相对定位
    相对于它在文档流中的原始位置进行定位
  • 绝对定位
    绝对定位元素脱离了文档流

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. box-sizing: border-box;
  13. }
  14. .box {
  15. /* position: relative; */
  16. /* position: absolute; */
  17. top: 5em;
  18. left: 10em;
  19. background-color: lightskyblue;
  20. width: 20rem;
  21. height: 4rem;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26. <div class="box">box</div>
  27. <p>Hello</p>
  28. </body>
  29. </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