index.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  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. <link rel="stylesheet" href="../css/index.css">
  8. </head>
  9. <body>
  10. <!--
  11. 网页页面:标准流 浮动 定位
  12. 定位:
  13. position
  14. 1.fixed 固定定位 相对于祖先元素 不占位脱离了文档流
  15. 2.sticky 粘性定位 占位不脱离文档流
  16. 3.static 静态定位
  17. 4.relative 相对定位 相对于元素本身 占位不脱离文档流
  18. 5.absolute 绝对定位 不占位脱离文档流
  19. a.当使用绝对定位时 父级元素中没有使用定位 相对于祖先元素定位
  20. b.当父级元素使用相对定位 则子元素相对于父级进行定位
  21. 位置:top bottom left right
  22. -->
  23. <div style="margin-top: 100px;border: 1px solid #000;width: 300px;height: 100%;position: relative;">
  24. <div class="box">1</div>
  25. <div class="box">2</div>
  26. <div class="special box">3</div>
  27. <div class="box">4</div>
  28. <div class="box">5</div>
  29. <div class="box">6</div>
  30. <div class="box">7</div>
  31. <div class="box">8</div>
  32. </div>
  33. </body>
  34. </html>