Twitter Bootstrap - 为什么行类有margin-left:-20px?

时间:2022-11-14 21:22:11

I don't understand why row class has margin-left: -20px (so it grows after parents border like on the image). I think nobody needs this behavior. Or am I doing something wrong?

我不明白为什么行类有margin-left:-20px(所以它会在父母像图像一样边界后增长)。我想没有人需要这种行为。或者我做错了什么?

<div class="container">
        <div id="top-container" class="row">
            <div class="span8">
                <h1>App</h1>
            </div>
            <div class="span4">

            </div>
        </div>
    </div>

Twitter Bootstrap  - 为什么行类有margin-left:-20px?

2 个解决方案

#1


11  

You can use row-fluid instead of row, then your span4 and span8 won't have margin-left.

你可以使用row-fluid而不是row,那么你的span4和span8将没有margin-left。

<div class="container">
    <div id="top-container" class="row-fluid">
        <div class="span8">
            <h1>App</h1>
        </div>
        <div class="span4">

        </div>
    </div>
</div>

#2


3  

For people trying to find this out for Bootstrap 3:

对于试图为Bootstrap 3找到这个的人:

Grids and full-width layouts Folks looking to create fully fluid layouts (meaning your site stretches the entire width of the viewport) must wrap their grid content in a containing element with padding: 0 15px; to offset the margin: 0 -15px; used on .rows.

网格和全宽布局想要创建完全流畅布局的人(意味着您的网站会拉伸视口的整个宽度)必须将其网格内容包装在包含填充的元素中:0 15px;抵消保证金:0 -15px;用于.rows。

Source (search for Grids and full-width layouts)

来源(搜索网格和全宽布局)

#1


11  

You can use row-fluid instead of row, then your span4 and span8 won't have margin-left.

你可以使用row-fluid而不是row,那么你的span4和span8将没有margin-left。

<div class="container">
    <div id="top-container" class="row-fluid">
        <div class="span8">
            <h1>App</h1>
        </div>
        <div class="span4">

        </div>
    </div>
</div>

#2


3  

For people trying to find this out for Bootstrap 3:

对于试图为Bootstrap 3找到这个的人:

Grids and full-width layouts Folks looking to create fully fluid layouts (meaning your site stretches the entire width of the viewport) must wrap their grid content in a containing element with padding: 0 15px; to offset the margin: 0 -15px; used on .rows.

网格和全宽布局想要创建完全流畅布局的人(意味着您的网站会拉伸视口的整个宽度)必须将其网格内容包装在包含填充的元素中:0 15px;抵消保证金:0 -15px;用于.rows。

Source (search for Grids and full-width layouts)

来源(搜索网格和全宽布局)