使用高度和宽度的百分比,您可以达到您想要的效果:
html, body, .page {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
.top-menu{
background: yellow;
height: 15%;
}
.left-menu{
background: blue;
float:left;
height: 75%;
}
.center{
background: red;
height: 75%;
}
.footer{
height: 10%;
background: green;
}
小提琴
编辑:根据您的评论,这是一个更新的解决方案:
一种选择是将 a min-height
on设置.center
为百分比。
使用 CSS 解决等高的侧边栏并不容易或直观。使用一种称为“人造列”的技术,该技术包括为背景图像.content
而不是.left-menu
直接为背景,您可以实现效果。我使用了 CSS3 渐变(使用带有 Compass 的 SCSS 使这更容易,但您可以手动完成所有浏览器前缀)。
更新的 CSS:
html, body, .page {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
.top-menu {
background: yellow;
height: 15%;
}
.left-menu {
float: left;
width: 25%;
}
.center {
background: red;
background: -webkit-gradient(linear, 0% 50%, 100% 50%, color-stop(0%, #0000ff), color-stop(25%, #0000ff), color-stop(25%, #ff0000));
background: -webkit-linear-gradient(left, #0000ff, #0000ff 25%, #ff0000 25%);
background: -moz-linear-gradient(left, #0000ff, #0000ff 25%, #ff0000 25%);
background: -o-linear-gradient(left, #0000ff, #0000ff 25%, #ff0000 25%);
background: linear-gradient(left, #0000ff, #0000ff 25%, #ff0000 25%);
min-height: 75%;
padding-left: 26%;
}
.footer {
height: 10%;
background: green;
}
p {
margin: 0;
}
笔