27_全屏大小元素.html 852 B

123456789101112131415161718192021222324252627282930313233
  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>Document</title>
  7. <style>
  8. *{
  9. margin: 0;
  10. }
  11. /* 块元素默认宽度为父元素宽度 */
  12. /* 块元素宽度百分比的值是相较于父元素的宽度 */
  13. /* 宽元素默认高度为内容高度 */
  14. .box{
  15. background-color: orange;
  16. /* width: 100%;
  17. height: 100%; */
  18. /* 绝对定位如果所有父元素都没有定位,那么就以body为参考点 */
  19. /* position: absolute; */
  20. position: fixed;
  21. top:0;
  22. left: 0;
  23. right: 0;
  24. bottom: 0;
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <div class="box"></div>
  30. </body>
  31. </html>