2_移动端常用的单位.html 999 B

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