0

我有一个带有容器和两列的页面。我的结构看起来像这样

<div id="page">
    <div id="left"></div>
    <div id="right"></div>
</div>

这是CSS

#page {
    min-height: 100%;
    height: 100%;
    width: 90%;
    font-size: 100%;
    margin: 0 auto 0 auto;
    padding: 0;
    font-size: 1em;
    position: relative;
}

#left {
    background-image: url("../images/layout/background.png");
    width: 198px;
    min-height: 100%;
    float: left;
}

#right {
    margin-left: 230px;
    min-height: 100%;
    background-color: #FFFFFF;
    border: 1px solid red;
    padding: 150px 20px 0px 20px;
    text-align: justify;
}

目前,使用前面的代码,#page元素不会延伸到底部,#left. 如果我从 , 中删除填充物#right#page并且#left#right.

我该如何解决这个问题?

4

1 回答 1

0

所以有几种方法可以处理这个问题。如果您希望只有两列具有不同背景且都到达其容器底部,则可以使用垂直重复的背景图像或 css3 渐变。我在这里设置了一个例子:

http://jsfiddle.net/29wBn/1/

注意#page 元素上的渐变背景

#page {
    background: -moz-linear-gradient(left, #b2f8ff 0%, #b2f8ff 50%, #9effaf 50%, #9effaf 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, right top, color-stop(0%,#b2f8ff), color-stop(50%,#b2f8ff), color-stop(50%,#9effaf), color-stop(100%,#9effaf)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(left, #b2f8ff 0%,#b2f8ff 50%,#9effaf 50%,#9effaf 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(left, #b2f8ff 0%,#b2f8ff 50%,#9effaf 50%,#9effaf 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(left, #b2f8ff 0%,#b2f8ff 50%,#9effaf 50%,#9effaf 100%); /* IE10+ */
    background: linear-gradient(to right, #b2f8ff 0%,#b2f8ff 50%,#9effaf 50%,#9effaf 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b2f8ff', endColorstr='#9effaf',GradientType=1 ); /* IE6-9 */
    overflow:hidden; /* make the container wrap the floated contents */
}

作为后备,#page 元素被分配左列颜色,右列接收它自己的颜色。

Chris Coyer 写了一篇很棒的文章,展示了几种不同的方式。 http://css-tricks.com/fluid-width-equal-height-columns/

于 2013-04-24T05:50:31.457 回答