Blogger Information
Blog 5
fans 0
comment 0
visits 2961
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
盒模型属性规则和em与rem应用场景
lucy
Original
481 people have browsed it

1.实例演示盒模型属性简写的规则
2.实例演示em与rem应用的场景,并分析区别与联系

  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. :root{
  9. /*当前字号的相对单位
  10. 用在 padding,margin, border-radius,用 em 比较合适
  11. px 通常用在边框上*/
  12. font-size: 1em;
  13. }
  14. .box{
  15. /*四个方向,按顺时针排列*/
  16. padding: 10px 15px 15px 20px;
  17. /* 当值只有三个时,第一个上, 第二个表示左右, 第三个表示下 */
  18. padding: 10px 30px 20px;
  19. /* 当值只有二个时,第一个表示上下, 第二个表示左右 */
  20. padding: 20px 40px;
  21. /* 四周都相同 */
  22. padding: 15px;
  23. /*rem根元素字体大小
  24. 用它做为字号的单位*/
  25. font-size: 1.5rem;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <div class="box">盒子</div>
  31. </body>
  32. </html>
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:本质上来说, rem是一个绝对值,具有可预测性
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