Negative left and right margin of .row class in Bo

2020-07-15 06:43发布

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?

2条回答
ら.Afraid
2楼-- · 2020-07-15 07:40

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.

查看更多
该账号已被封号
3楼-- · 2020-07-15 07:43

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.

查看更多
登录 后发表回答