选择器填充可用空间之前的CSS

时间:2013-08-20 11:22:05

标签: html css twitter-bootstrap css-selectors

有没有办法让前选择器填充空闲的右侧空间并保持左侧不受影响?

Example

我希望红线填满可用空间的右侧,是否可以实现?

.grey {
    border-left:1px solid #d1d1d1;
    background: #e0e0e0;
}

    .grey:before {
        content:'';
        width:100%;
        height:100%;
        background:red;
        position:absolute;
        z-index:-99;
    }

我正在使用Bootstrap RC2。 .grey类已添加到col-4 div。

我希望屏幕的左侧不受影响,但是右侧要填充“红色”。 颜色应从col-4 div开始。

1 个答案:

答案 0 :(得分:1)

尝试使用calc()

示例 FIDDLE

.container:before{
    content: '';
    height: 100%;
    background: red;
    position: absolute;
    top:0;
    right: 0;
    width: calc(((100% - 1170px)/2));
}