0
    <div class="row">
        <div id="cover" class="span12"></div>
    </div>
    <div class="row">
        <div id="first_left" class="span6 left">
            <h3>aa</h3>

        </div>
        <div id="first_right" class="span5">
            ee
        </div>
    </div>

And less:

#cover{
    background: url('couv.jpg') no-repeat;
    width: 960px;
    height: 280px;
}

h3{
    color: #212121;
    font-size: 18px;
    font-weight: normal;
    float: left;
    text-transform: uppercase;
    margin: 0 0 25px 0;
    text-shadow: 1px 2px 2px #FFF;
}

.left{
    background: url('grille.jpg');
    padding: 15px;
}

The "first_right" span displays below first_left, and only if the 15px padding is present. With padding 15, first_left becomes 490px wide instead of 460px. Why is that ? Also, is it ok to have padding on a span if I want to nest some more rows in it ?

4

1 回答 1

1

box-sizing的默认值为content-box。这不包括padding. 扩展元素的padding宽度(如果设置)。您需要设置在元素宽度中border-box包含paddingand 。borders

.left{
    background: url('grille.jpg');
    padding: 15px;
    box-sizing: border-box;
}

现在宽度包括填充和边框。

阅读有关盒子尺寸的更多信息

于 2013-05-21T09:11:20.727 回答