【问题标题】:fill remaining space with div width auto用 div width auto 填充剩余空间
【发布时间】:2015-10-14 05:29:58
【问题描述】:

大家好,感谢即将到来的支持我如何设置蓝色来填充整个 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/

【问题讨论】:

  • 我的意思是整个,我很抱歉并会修复它。

标签: html css width


【解决方案1】:

如果只是 .maininfo,只需添加一个“背景:蓝色;”样式声明的属性:

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

否则,只需添加一个“背景:蓝色;” “body”元素的属性:

    body {
      background-color: blue;
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-02
    相关资源
    最近更新 更多