1

メイン div に 4 つの div があります。すべてが左に浮かんでいて、最後の 1 つは空のスペースを残します。そのスペースを最後の div (全幅) で埋めたいと思います。

http://jsfiddle.net/jZpWf/26/

<div id="container">
    <div class="col1">
    </div>
    <div class="col2">
    </div>
    <div class="col3">
    </div>    
    <div class="col4">
    </div>    
</div>

#container {
    width: 600px;
    height: 200px;
    background:yellow;
}
.col1 {
    float:left;
    width:90px;
    height: 200px;
    background:red;
}
.col2 {
    float:left;
    width:130px;
    background:blue;
height: 200px;    
}
.col3 {
    float:left;
    width:130px;
    background:red;
    height: 200px;
}
.col4 {
    float:left;
    width:130px;
    background:blue;
    height: 200px;
}
4

3 に答える 3

4

左に浮かせずに 100% にして、残りのスペースをすべて埋めます。

.col4 {
    background:blue;
    height: 200px;
}

デモを試す

于 2013-04-24T19:20:28.153 に答える
1
.col4 {
    float:left;
    width: 250px;
    background:blue;
    height: 200px;
}

簡単な答え、すぐに良いもの...

より良いもの、jfiddle

于 2013-04-24T19:15:35.040 に答える
0

div の幅の合計は、使用可能な合計サイズに対応しないため、合計領域を占有しないでください。これは、パーセンテージ メソッドまたは CSS3 calc を使用して行うことができます

.col4 のサイズ変更

.col4 {
    float:left;
    width:250px;
    background:blue;
    height: 200px;
}

また

CSS3でCol4を計算する

.col4 {
    float:left;
    width: calc(100% - 350px);
    background:blue;
    height: 200px;
}
于 2013-04-24T19:17:14.730 に答える