2个固定宽度的侧栏,中央div可填充剩余空间

时间:2014-04-16 13:37:41

标签: css

如何将绿色div width: 100%与另外两个div放在固定width的同一行。

我的想法是让双方div的宽度固定,中央divwidth: 100%(占用剩余空间)。

是否可以实施这种情况?

CSS:

.boxMenu {
    width:200px;
    height:40px;
    background-color:#000;
    float:left;
}
.boxConteudoMaster {
    height:40px;
    background-color:#4cff00;
    float:left;
}
.boxNotificacao {
    width:200px;
    height:40px;
    background-color:#000;
    float:left;
}

HTML:

<div class="boxMenu"></div>
<div class="boxConteudoMaster">asd</div>
<div class="boxNotificacao"></div>

JSFIDDLE HERE

1 个答案:

答案 0 :(得分:1)

我认为你的事情是这样的:

HTML:

<div class="boxMenu"></div>
<div class="boxNotificacao"></div>
<div class="boxConteudoMaster">Testing...</div>

CSS:

.boxMenu {
    width:200px;
    height:40px;
    background-color:#000;
    float:left;
}
.boxConteudoMaster {
    height:40px;
    background-color:#4cff00;
    width: 100%;
}
.boxNotificacao {
    width:200px;
    height:40px;
    background-color:#000;
    float:right;
}

因此,我们可以浮动我们想要修复的2 divfloat:leftfloat: right),然后在放置后divwidth: 100%

DEMO HERE