在引导程序中,.row类的左和右边界为负

时间:2022-11-14 21:26:39

Just out of curiosity, why bootstrap uses -15px left and right margins which going to cancel the 15px left and right padding on .container and .container-fluid classes.
Why set padding and then cancel it with a negative margin on the child?

出于好奇,为什么bootstrap使用-15px左右边距来取消。container和。container-fluid类上的15px左右边距。为什么要设置填充,然后在子对象上使用负的空白来取消它?

2 个解决方案

#1


1  

As in Official Bootstrap Website said:

正如在官方引导网站上所说:

Rows are wrappers for columns. Each column has horizontal padding (called a gutter) for controlling the space between them. This padding is then counteracted on the rows with negative margins. This way, all the content in your columns is visually aligned down the left side.

行是列的包装器。每一列都有水平填充(称为排水沟)来控制它们之间的空间。然后,在具有负边距的行上抵消这种填充。这样,列中的所有内容在视觉上都沿着左侧对齐。

#2


1  

A negative margin on row avoids the blank space that would be left because of padding of first column. In its absence the whole layout will look a little indented.

行上的负边距避免了由于第一列的填充而留下的空白空间。如果没有它,整个布局看起来会有点缩进。

#1


1  

As in Official Bootstrap Website said:

正如在官方引导网站上所说:

Rows are wrappers for columns. Each column has horizontal padding (called a gutter) for controlling the space between them. This padding is then counteracted on the rows with negative margins. This way, all the content in your columns is visually aligned down the left side.

行是列的包装器。每一列都有水平填充(称为排水沟)来控制它们之间的空间。然后,在具有负边距的行上抵消这种填充。这样,列中的所有内容在视觉上都沿着左侧对齐。

#2


1  

A negative margin on row avoids the blank space that would be left because of padding of first column. In its absence the whole layout will look a little indented.

行上的负边距避免了由于第一列的填充而留下的空白空间。如果没有它,整个布局看起来会有点缩进。