gpt4 book ai didi

css - Div 高度 100% 格式化问题

转载 作者:太空宇宙 更新时间:2023-11-04 15:12:16 27 4
gpt4 key购买 nike

我正在尝试让侧边栏填充页眉和页脚之间的高度。如您所见,它位于页脚后面。我希望它停在页脚的顶部。任何帮助都会很棒!

演示地址:http://www.jsfiddle.net/pEbhK/

HTML:

<div class="header">
<h2>Development Area</h2>
</div>
<div class="sidebar">
<h2>Current Projects</h2>
<ul>
<li>iCalendar</li>
<li>MyBand - Student Center</li>
</ul>
<h2>Future Projects</h2>
<ul>
<li>Mobile Application</li>
<li>RSS Feed</li>
</ul>
</div>
<div class="clear"></div>
<div class="footer">&copy; 2013</div>

CSS:

html, body, h1, h2 {
margin:0px;
padding:0px;
}
.clear {
clear:both;
}
.header {
display:inline-block;
width:100%;
background:#ABBFF2;
height:100px;
border-bottom: 5px solid #7F9DEB;
text-align:center;
}
.header h2 {
padding-top:38px;
}
.sidebar {
position: fixed;
height:100%;
width:250px;
background:#ABBFF2;
border-right:5px solid #7F9DEB;
float:left;
}
.sidebar h2 {
text-align:center;
}
.footer {
position:fixed;
display:inline-block;
bottom:0px;
width:100%;
height:30px;
border-top:5px solid #7f9deb;
text-align:center;
}

最佳答案

.sidebar 中尝试 height:calc(100% - 140px)

.sidebar {
position: fixed;
height:calc(100% - 140px);
width:250px;
background:#ABBFF2;
border-right:5px solid #7F9DEB;
float:left;
}

updated jsFiddle File

关于css - Div 高度 100% 格式化问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18615225/

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