【发布时间】:2010-11-17 03:04:05
【问题描述】:
我正在尝试使用 DIV 模拟框架来制作 CSS 页面布局。
我想要一个固定的顶部窗格,它具有固定的高度,并且宽度会随着页面大小的调整而伸缩。 (固定含义如果用户向下滚动页面,顶部窗格始终可见)
下面我想要两列。当您调整窗口大小时,左栏的宽度固定,右栏的宽度会延伸。必要时两列都应该有垂直滚动条。
我的代码在 Chrome 中似乎可以正常工作,但在 IE 中,滚动条不显示在左侧或右侧列中。
我可以做些什么来解决这个问题吗?也许一些 javascript 告诉 IE 正确绘制滚动条?
风格:
body{
margin: 0px;
padding: 0px;
border: 0px;
overflow: hidden;
height: 100%;
max-height: 100%;
}
#framecontentTop{
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 108px; /*Height of frame div*/
overflow: hidden; /*Disable scrollbars. Set to "scroll" to enable*/
background-color: navy;
color: white;
}
#framecontent{
position: absolute;
top: 108px;
left: 0px;
bottom: 0px;
width: 200px; /*Width of frame div*/
float:right;
overflow: auto; /*Disable scrollbars. Set to "scroll" to enable*/
background: navy;
color: white;
/*padding: 108px 0 0 200px; */ /*Set value to (0 0 0 WidthOfFrameDiv)*/
}
#maincontent{
position: absolute;
top: 108px;
left: 200px; /*Set left value to WidthOfFrameDiv*/
right: 0px;
bottom: 0px;
float:right;
overflow: auto;
background: #fff;
}
* html body { /*IE6 hack*/
}
* html #maincontent{ /*IE6 hack*/
height: 100%;
width: 100%;
}
脚本:
<script type="text/javascript">
/*** Temporary text filler function. Remove when deploying template. ***/
var gibberish=["This is just some filler text", "Welcome to Dynamic Drive CSS Library", "Demo content nothing to read here"]
function filltext(words){
for (var i=0; i<words; i++)
document.write(gibberish[Math.floor(Math.random()*3)]+" ")
}
</script>
html 正文:
<div id="framecontentTop">
<h1>CSS Top Frame Layout</h1>
<h3>Sample text here</h3>
</div>
<div id="framecontent">
<h1>CSS Left Frame Layout</h1>
<p><script type="text/javascript">filltext(25)</script></p>
</div>
<div id="maincontent">
<h1>Dynamic Drive CSS Library</h1>
<p><script type="text/javascript">filltext(255)</script></p>
<p style="text-align: center">Credits: <a href="http://www.dynamicdrive.com/style/">Dynamic Drive CSS Library</a></p>
</div>
</body>
</html>
【问题讨论】:
-
请重新格式化您问题中的代码,输入框下方的框(textarea),您可以在提交之前预览您的帖子。
标签: css internet-explorer scroll positioning frames