div固定位置,不随滚动条滚动

Html代码 复制代码 收藏代码
  1. <html>
  2. <head>
  3. <title>div固定位置,不随滚动条滚动</title>
  4. <style type="text/css">
  5. html,body {
  6. overflow:hidden;
  7. margin:0px;
  8. 100%;
  9. height:100%;
  10. }
  11. .virtual_body {
  12. 100%;
  13. height:100%;
  14. overflow-y:scroll;
  15. overflow-x:auto;
  16. }
  17. .fixed_div {
  18. position:absolute;
  19. z-index:2008;
  20. bottom:20px;
  21. left:40px;
  22. 800px;
  23. height:40px;
  24. border:1px solid red;
  25. background:#e5e5e5;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <div class="fixed_div">我永远在这里,哪也不去</div>
  31. <div class="virtual_body">
  32. <div style="height:888px;">
  33. <br/><br/><br/><br/><br/><br/><br/><br/><br/>
  34. 滚动条是把杀猪刀
  35. </div>
  36. </div>
  37. </body>
  38. </html>
原文地址:https://www.cnblogs.com/bjanzhuo/p/3576089.html