Html div上带有溢出的滚动条:自动和百分比高度
是否可以创建一个可根据浏览器大小进行调整并可滚动的div? 我想在div上使用Html div上带有溢出的滚动条:自动和百分比高度,html,scroll,height,overflow,percentage,Html,Scroll,Height,Overflow,Percentage,是否可以创建一个可根据浏览器大小进行调整并可滚动的div? 我想在div上使用overflow:auto和90%的百分比高度 页面的结构如下所示 <body style="height:100%"> <div id=header style="height:100%">headerinfo</div> <div id=content style="height:100%;overflow:auto">content which is replace
overflow:auto
和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>
校长信息
动态替换的内容
overflow:auto
在层次结构中没有已知的px
高度的情况下会工作吗?在回答您的问题时,是的overflow:auto
会工作,但HTML标记上也需要height:100%
:
html,body {
height:100%;
margin: 0;
}
#header {
height: 100%;
}
#content {
height: 100%;
overflow: auto;
}
但是,标记的结构方式将生成两个div,两个div的高度都与视口相同,一个位于另一个之上。这是你的本意吗
如果是这样的话,这里有一个JSFIDLE来说明您的示例。我已经调整了标记并添加了额外的内容,以便contentdiv可以根据需要溢出
我很惊讶!id=标题有效!(不带引号)。DOM标记可以用作ID似乎很疯狂…