我有一个页面,在页面的左侧有一个垂直导航栏,右侧是“内容”区域。我想让“内容”区域的宽度填满屏幕剩余空间,高度与导航栏高度相同。
目前我已经有了以下代码:jsFiddle 最好能够找到一个纯 CSS 的解决方案。
目前我已经有了以下代码:jsFiddle 最好能够找到一个纯 CSS 的解决方案。
<div id="header"></div>
<div id="wrapper">
<div id="sidebar"></div>
<div id="content"></div>
</div>
<div id="footer"></div>
就拉伸内容而言,您的CSS会为您完成工作:
/* The top part of the rounded container */
#header {
background: url(images/bg_top.gif) 100% 100% no-repeat; /* sit on top */
}
/* The background for your content */
#wrapper {
background: url(images/bg_tile.gif) 100% 0 repeat-y; /* repeat on the right */
}
/* The bottom of your content */
#footer {
background: url(images/bg_bottom.gif) 100% 0 no-repeat; /* sit on the bottom */
}
你肯定需要调整一些负边距来让元素完美的排列。
为您的内容区域应用最小高度:
#content {
position: absolute;
margin-left: 200px;
width: 100%;
min-height:328px;
}
请查看更新的代码片段:http://jsfiddle.net/hsGN6/6/
虽然有点粗糙,但它能正常工作。
min-height
CSS 属性可以完成工作,但每次添加另一个链接时都必须更改 CSS。我会再找一些自动缩放的解决方案。 - Patrick M