如何将背景颜色调整到合适的高度

时间:2014-07-22 18:58:27

标签: css twitter-bootstrap background-color

我正在使用cakephp和twitter bootstrap在PHP网站上工作。 我正试图在右边的单元格上添加背景颜色。我希望背景颜色覆盖所有细胞。该单元格的高度必须与左侧部分(col-xs-4)相同。现在,我有背景颜色,如何只覆盖col-xs-7单元格的内容。

<div class="row">
    <div class="col-xs-4">
        <div class="row ">
            <div class="col-xs-12">
                <?php echo $this->Html->image("/img/internet_background_green.png", 
                                              array("class"=>"imgResponsive"));?>
            </div>
            <div class="col-xs-12 paddingTop20px" >
                <?php echo $this->Html->image("/img/internet_background_green.png",
                                              array("class"=>"imgResponsive"));?>
            </div>
        </div>

    </div>
    <div class="col-xs-7 bgcLightGray marginLeft20px">
        <?php echo $this->Html->image("/img/internet.png");?>
    </div>
</div>

与该部分相关的CSS:

.bgcLightGray {
    background-color: #bdbcbc;
}
.marginLeft20px {
    margin-left: 20px;
}
.paddingTop20px {
    padding-top: 20px;
}
.row {
    padding: 0;
    margin: 0;
}

Here's my fiddle

1 个答案:

答案 0 :(得分:2)

就CSS解决方案而言,您需要为两个div指定一个特定的高度。

如果您不想让CSS合作,可以使用javascript。

$('1stDiv').height($('2ndDiv').height());

演示:http://jsfiddle.net/3ENy2/2/