✔ 最佳答案
Fixed layer with CSS "overflow: auto"
This is a simulation of CSS "position: fixed" for MSIE. The main text on this page is contained in a 100% high, scrollable <div>. The scrollbar belongs to the <div>, not to the <body>. The ordinary <body> content is found in the fixed green box. All HTML and CSS on this page should follow the W3C spec except overflow-y: hidden, which is used for cosmetical purposes in earlier IE versions.
********************************
<style type="text/css">
<!--
body {margin: 0; padding: 0; font-size: 100%;}
li {margin: 0.5em; }
code {background: #fff; color: #4B0082; }
div.innerbox {padding: 4em 5%; }
div.fixedcontent {position: fixed; z-index: 2; top: 1em; left: 5%; width: auto; padding: 0.3em; border: 5px dashed; color: #000; background: #cfc; }
.fixedcontent p {margin: 0; padding: 0;}
-->
</style>
<!--[if gte IE 5]>
<style type="text/css">
html,body {height: 100%; overflow-y: hidden;} /* Prevents double scrollbars. */
div.scrollingcontent {height: 100%; width: 100%; overflow: auto; margin: 0; padding: 0; }
div.fixedcontent {position: absolute; z-index: 2; }
</style>
<![endif]-->
</head>
<body>
<div class="scrollingcontent">
<div class="innerbox">
<h1>
Fixed layer with CSS "overflow: auto"
</h1>
<p>
This is a simulation of CSS "position: fixed" for MSIE. The main text on this page is contained in a 100% high, scrollable <code><div></code>. The scrollbar belongs to the <code><div></code>, not to the <code><body></code>. The ordinary <code><body></code> content is found in the fixed green box.
All HTML and CSS on this page should follow the W3C spec except <code>overflow-y: hidden</code>, which is used for cosmetical purposes in earlier IE versions.
</p>
********************************