2_移动端常用的单位.html 1.0 KB

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