用div宽度auto填充剩余空间

时间:2014-09-27 02:03:26

标签: html css width

嘿,大家好,感谢即将到来的支持,如何设置蓝色以填满整个maininfo div的剩余宽度?我尝试设置 width:auto

<div class="maininfo">
    <div class="large">2</div>
    <div class="smallblock">
        <div class="smalltop">3</div>
        <div class="small">4</div>
    </div>
    <div class="smallblock">
        <div class="smalltop">5</div>
        <div class="small">6</div>
    </div>
</div>

.maininfo {

    width: 600px;

}

.large {
    float: left;
    height: 95px;
    background-color: blue;
    width:auto;
}


.smallblock {
    float: right;
    height: 90px;
    margin: 0 0 0 5px;
    width: 20%;
}

.small {
background-color: red;
height: 50%;
width: 100%;
}
.smalltop {
background-color: red;
height: 50%;
width: 100%;
margin-bottom:5px;
}

更新我的JFIDDLE但现在它制造了2条线:http://jsfiddle.net/4ykf5frk/11/

1 个答案:

答案 0 :(得分:1)

如果只是.maininfo,只需添加'background:blue;'属性风格声明:

    .maininfo {
      background-color: blue;
      width: 600px;
    }

否则,只需添加'背景:蓝色;' 'body'元素的属性:

    body {
      background-color: blue;
    }