gpt4 book ai didi

css - 如何保持页眉、页脚和外部 div 固定并使内部 div 可滚动

转载 作者:行者123 更新时间:2023-11-28 18:32:12 25 4
gpt4 key购买 nike

请看这个http://jsfiddle.net/jaseem/sS7HN/ .我想要实现的是而不是内部滚动条,我想使用主窗口滚动条;这样我就可以使用 Windows 垂直滚动条浏览“innerContent”内的内容,但同时我希望修复外部 div。这可能吗?

CSS:

header {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 50px;
}

footer {
position: fixed;
left: 0;
bottom:0;
width: 100%;
}

content {
background-color:#656565;
width: 940px;
margin:0 auto;
padding-top:10px;
border-radius:5px;
}

mainContent {
margin:0px auto;
background-color:#515151;
width:660px;
border-radius:5px;
padding-top:20px;
}

contentHolder {
margin:0 auto;
width:616px;
background-color:#000000;
border-radius:10px;
overflow:auto;
}

HTML:

<div id="header"></div>
<div id="content">
<div id="mainContent">
<div id="contentHolder"></div>
</div>
</div>
<div id="footer"></div>

最佳答案

有点不清楚您要完成什么,但我确实注意到您缺少 CSS 中的井号标签。如果您指的是 ID 属性,则需要在标识符前面加上 #

示例:http://jsfiddle.net/hgcax/

CSS

#header {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 50px;
}

#footer {
position: fixed;
left: 0;
bottom:0;
width: 100%;
}

#content {
background-color:#656565;
width: 940px;
margin:0 auto;
padding-top:10px;
border-radius:5px;
}

#mainContent {
margin:0px auto;
background-color:#515151;
width:660px;
border-radius:5px;
padding-top:20px;
}

#contentHolder {
color:#fff;
margin:0 auto;
width:600px;
height: 400px;
background-color:#000000;
border-radius:10px;
overflow:auto;
}​

关于css - 如何保持页眉、页脚和外部 div 固定并使内部 div 可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13965222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com