【问题标题】:Child div full width - margins子 div 全宽 - 边距
【发布时间】:2013-11-04 16:55:54
【问题描述】:

我有一组嵌套的 div。我希望内部 div 获得完整宽度,而不使用比父 div 和左右边距更多的宽度。我尝试了 max-width:100% 但到目前为止还没有奏效。在这个例子中,#test2 应该是全宽 - margin-left

HTML

<div id="test">
    <div id="test2">
        <div>123</div>
    </div>
</div>
<div id="test3"></div>

CSS

#test{
    width:100%;
    height:100px;
    float:left;
}
#test2{
    margin-left:51px;
    float:left;
    width:100px;
    max-width:100%;
    background:blue;
    height:100px;
}
#test3{
    width:50px;
    float:left;
    background:red;
    height:100px;
    margin-left:-100%;
}

JS FIDDLE

我想在不使用 javascript 或任何新的 CSS 命令(如 calc)的情况下让它工作 有指针吗?

【问题讨论】:

  • 我没有得到你想要的,你能解释一下吗?

标签: html css


【解决方案1】:

试试这个,

min-width:100px;
width:100%;

【讨论】:

    【解决方案2】:

    带走宽度:100px;并使其宽度:100%;像这样:

    #test2{
    margin-left:51px;
    float:left;
    width:100%;
    background:blue;
    height:100px;
    }
    

    【讨论】:

      【解决方案3】:

      看看这个:

      @987654321@

      希望它能解决你的问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-11-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-02-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多