tec*_*dog 7 html height scroll overflow percentage
是否可以创建一个调整到浏览器大小的div,也可以滚动?我想用overflow:autodiv和百分比高度90%.
页面的结构是
<body style="height:100%">
<div id=header style="height:100%">headerinfo</div>
<div id=content style="height:100%;overflow:auto">content which is replaced dynamically</div>
</body>
Run Code Online (Sandbox Code Playgroud)
将overflow:auto工作没有已知px的某处层次结构中的高度?
Chr*_*les 10
在回答你的问题时,肯定overflow:auto会有效,但你也需要height: 100%在HTML标签上:
html,body {
height:100%;
margin: 0;
}
#header {
height: 100%;
}
#content {
height: 100%;
overflow: auto;
}
Run Code Online (Sandbox Code Playgroud)
构建标记的方式虽然会产生两个div,它们的高度与视口的高度相同.这是你的意图吗?
如果是这样,这里有一个jsFiddle来说明你的例子.我已经调整了标记并添加了其他内容,以便内容div可以根据需要溢出.
http://jsfiddle.net/chrissp26/WsNjm/