2_移动端的单位.html 991 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. }
  13. #div1{
  14. /* rem 相对于根元素html字体的大小 */
  15. /* rem = 50px */
  16. width: 3rem;
  17. height: 3rem;
  18. background: red;
  19. /* font-size: 50px; */
  20. }
  21. #div2{
  22. /* em 是根据父元素的字体大小 */
  23. /* em = 16px */
  24. /* width: 2em;
  25. height: 100px; */
  26. background: yellow;
  27. /* width: 50%;
  28. height: 50%; */
  29. }
  30. #div3{
  31. width: 100%;
  32. height: calc(100vh - 100px);
  33. background: blue;
  34. }
  35. /* vh vw 相当于视口 设备 */
  36. </style>
  37. </head>
  38. <body>
  39. <div id="div1">
  40. <div id="div2"></div>
  41. </div>
  42. <div id="div3"></div>
  43. <script src="rem.js"></script>
  44. <!--
  45. 325 150
  46. 820 328
  47. -->
  48. </body>
  49. </html>