打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
DIV固定在页面某个位置,不随鼠标滚动而滚动
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">  
  2. <!-- saved from url=(0050)http://www.pmob.co.uk/temp/fixedlayoutexample5.htm -->  
  3. <HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Fixed header and footer for IE</TITLE>  
  4. <META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>  
  5. <STYLE type=text/css>BODY {  
  6. MARGIN: 0px  
  7. }  
  8. HTML {  
  9. PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; HEIGHT: 100%; PADDING-TOP: 0px  
  10. }  
  11. BODY {  
  12. PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; HEIGHT: 100%; PADDING-TOP: 0px  
  13. }  
  14. * HTML {  
  15. PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; OVERFLOW: hidden; PADDING-TOP: 0px  
  16. }  
  17. * HTML BODY {  
  18. PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; OVERFLOW: hidden; PADDING-TOP: 0px  
  19. }  
  20. * HTML #outer {  
  21. HEIGHT: 99.9%; OVERFLOW: auto; voice-family: inherit  
  22. }  
  23. * HTML #contain-all {  
  24. Z-INDEX: 1; POSITION: absolute; OVERFLOW-Y: scroll; WIDTH: 100%; HEIGHT: 100%  
  25. }  
  26. #top-bar {  
  27. Z-INDEX: 999; POSITION: absolute; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; HEIGHT: 50px; OVERFLOW: hidden; TOP: 0px; PADDING-TOP: 0px; LEFT: 0px  
  28. }  
  29. #topbar-inner {  
  30. BACKGROUND: red; HEIGHT: 50px  
  31. }  
  32. #footer-inner {  
  33. BACKGROUND: red; HEIGHT: 50px  
  34. }  
  35. * HTML #topbar-inner {  
  36. MARGIN-RIGHT: 17px  
  37. }  
  38. * HTML #footer-inner {  
  39. MARGIN-RIGHT: 17px  
  40. }  
  41. #footer {  
  42. Z-INDEX: 999; POSITION: absolute; WIDTH: 100%; BOTTOM: 0px; HEIGHT: 50px  
  43. }  
  44. .spacer {  
  45. HEIGHT: 50px  
  46. }  
  47. P {  
  48. MARGIN-TOP: 0px  
  49. }  
  50. HTML > BODY #top-bar {  
  51. POSITION: fixed  
  52. }  
  53. HTML > BODY #footer {  
  54. POSITION: fixed  
  55. }  
  56. </STYLE>  
  57.   
  58. <META name=GENERATOR content="MSHTML 8.00.7600.16490"></HEAD>  
  59. <BODY>  
  60. <DIV id=outer>  
  61. <DIV id=contain-all>  
  62. <DIV is an experimental layout and untested in a real situation but   
  63. preliminary results look good.</P>  
  64. <P>The header and footer need to be a fixed height and are therefore not suited   
  65. to large amounts of fluid content.</P>  
  66. <P>The code comments for ie are documented below as they needed to be removed   
  67. from the code for ie mac</P>  
  68. <P>* html, * html body{<BR>overflow:hidden;/* remove scroll mechanism from   
  69. body*/<BR>padding:50px 0;/* for ie5 and 5.5.*/<BR>margin:-50px   
  70. 0;<BR>padd\ing:0;<BR>margin:0;<BR>}</P>  
  71. <P>* html #outer { <BR>overflow:auto;/* this is basically the root element   
  72. now*/<BR>height:100%;<BR>/* we need to make ie5 jump the next style block (   
  73. contain-all) so we use the voice hack*/<BR>voice-family: "\"}\"";   
  74. voice-family:inherit; <BR>}<BR>* html #contain-all{/* must contain all content   
  75. except for top and bottom bars - ie5 doesnt want this so jumps it as mentioned   
  76. above*/<BR>position:absolute;/* due to a bug in ie6 where children of elements   
  77. that have overflow defined behave as those they are   
  78. fixed*/<BR>overflow-y:scroll;<BR>width:100%;<BR>height:100%;<BR>z-index:1;<BR>}<BR></P>  
  79. <P> </P>  
  80. <P>some text to wrap : some text to wrap : some text to cause scrolling : : some   
  81. text to wrap : some text to wrap : some text to cause scrolling : : some text to   
  82. wrap : some text to wrap : some text to cause scrolling : : some text to wrap :   
  83. some text to wrap : some text to cause scrolling : : some text to wrap : some   
  84. text to wrap : some text to cause scrolling : : some text to wrap : some text to   
  85. wrap : </P>  
  86. <P>some text to cause scrolling : </P>  
  87. <P>some text to cause scrolling : </P>  
  88. <P>some text to cause scrolling : </P>  
  89. <P>some text to cause scrolling : </P>  
  90. <P>some text to cause scrolling : </P>  
  91. <P>some text to cause scrolling : </P>  
  92. <P>some text to cause scrolling : </P>  
  93. <P>some text to cause scrolling : </P>  
  94. <P>some text to cause scrolling : </P>  
  95. <P>some text to cause scrolling : </P>  
  96. <P>some text to cause scrolling : </P>  
  97. <P>some text to cause scrolling : </P>  
  98. <P>some text to cause scrolling : </P>  
  99. <P>some text to cause scrolling : </P>  
  100. <P>some text to cause scrolling : </P>  
  101. <P>some text to cause scrolling : </P>  
  102. <P>some text to cause scrolling : </P>  
  103. <P>some text to cause scrolling : </P>  
  104. <P>some text to cause scrolling : </P>  
  105. <P>some text to cause scrolling : </P>  
  106. <P>some text to cause scrolling : </P>  
  107. <P>some text to cause scrolling : </P>  
  108. <P>some text to cause scrolling : </P>  
  109. <P>some text to cause scrolling : </P>  
  110. <P>some text to cause scrolling : </P>  
  111. <P>some text to cause scrolling : </P>  
  112. <P>some text to cause scrolling : </P>  
  113. <P>some text to cause scrolling : </P>  
  114. <P>some text to cause scrolling : </P>  
  115. <P>some text to cause scrolling : </P>  
  116. <P>some text to cause scrolling : </P>  
  117. <P>some text to cause scrolling : </P>  
  118. <P>some text to cause scrolling : </P>  
  119. <P>some text to cause scrolling : </P>  
  120. <P>some text to cause scrolling : </P>  
  121. <P>some text to cause scrolling : </P>  
  122. <P>some text to cause scrolling : </P>  
  123. <P>some text to cause scrolling : </P>  
  124. <P>some text to cause scrolling : </P>  
  125. <P>some text to cause scrolling : </P>  
  126. <P>some text to cause scrolling : </P>  
  127. <P>some text to cause scrolling : </P>  
  128. <P>some text to cause scrolling : </P>  
  129. <P>some text to cause scrolling : </P>  
  130. <P>some text to cause scrolling : </P>  
  131. <P>some text to cause scrolling : </P>  
  132. <P>some text to cause scrolling : </P>  
  133. <P>some text to cause scrolling : </P>  
  134. <P>some text to cause scrolling : </P>  
  135. <P>some text to cause scrolling : </P>  
  136. <P>some text to cause scrolling : </P>  
  137. <P>some text to cause scrolling : </P>  
  138. <P>Last bit of text</P>  
  139. <DIV id=top-bar>  
  140. <DIV id=topbar-inner>Fixed Top & bottom- Demo works in IE5 IE5.5. and ie6 -   
  141. Firefox 1.0+, Mozilla 1.3+, NN 6.2, Opera 6.03 7.2 7.5,8 : (Mac OS X 10.4 -   
  142. FireFox 1.5.0.1, Safari 2.0.3 (417.8), IE 5.2 (5.2.3 (5815.1)) </DIV></DIV>  
  143. <DIV id=footer>  
  144. <DIV id=footer-inner>Fixed footer </DIV></DIV></BODY></HTML>  

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
设计者必须掌握的53个CSS技巧
CSS/层叠样式表
CSS教程:十步学会用css建站
css *n
优化你的css
CSS
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服