Blogger Information
Blog 19
fans 0
comment 0
visits 5755
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
em,rem,vw,vh在实例中的演示
vbokok
Original
228 people have browsed it
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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>css常用单位em和rem</title>
  8. </head>
  9. <body>
  10. <header>页眉</header>
  11. <main>
  12. <!-- font-size = 16px -->
  13. <div>Hello</div>
  14. <!-- font-size = 20px -->
  15. <div style="font-size:1.25rem">World</div>
  16. <!-- font-size = 32px -->
  17. <div style="font-size:2rem">china</div>
  18. <div class="box">box</div>
  19. </main>
  20. <footer>页脚</footer>
  21. </body>
  22. </html>
  23. <style>
  24. html {
  25. width: 100vw;
  26. height: 100vh;
  27. }
  28. * {
  29. margin: 0;
  30. padding: 0;
  31. box-sizing: border-box;
  32. }
  33. body > * {
  34. outline: 1px solid;
  35. background-color: aqua;
  36. }
  37. header,footer {
  38. width: 100vw;
  39. height: 5vh;
  40. }
  41. main {
  42. background-color: aquamarine;
  43. width: 100vw;
  44. margin: 1vh 0;
  45. /* calc()运算需要在运算符两边要加空格,乘除法不用加 */
  46. min-height: calc(100vh - 5vh - 5vh - 2vh);
  47. }
  48. .box {
  49. background-color: bisque;
  50. width: 50vw;
  51. height: 50vh;
  52. border: 2px solid red;
  53. margin: 5px;
  54. padding: 10px;
  55. }
  56. </style>

Correcting teacher:PHPzPHPz

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