Why 15px in .container and -15px in .row?

Asked 2 years ago, Updated 2 years ago, 79 views

Basically, Bootstrap is written in .container and describes .row.
But why does Bootstrap bother .container with 15px and .row with -15px?

Affected Source Links:
https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap-grid.css#L22
https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap-grid.css#L62

css twitter-bootstrap

2022-09-30 17:12

2 Answers

If you only write .row in .container, it is useless to do 15px in .container and -15px in .row.

However, .container is a container as the name suggests, so I often put something other than .row.For example, considering the example below, .container uses 15px and -15px uses .row to align the title, sentence, and in the grid.In short, it's to make it easier for developers to use.

<div class="container">
  <h2>Title </h2>
  <p> Sentences <p>
  <div class="row">
    <div class="col-sm">
      One of three columns
    </div>
    <div class="col-sm">
      One of three columns
    </div>
    <div class="col-sm">
      One of three columns
    </div>
  </div>
</div>


2022-09-30 17:12

If you use minus margin in row, you can put plus margin elements in it.
Maybe it's because it's the purpose?

I think I can put several boxes in the row with float, but it automatically folds back cleanly
It seems to have been an ingenuity to display...

I found a site explaining that part
You can also specify a negative value!

With Bootstrap, you don't know these CSS tricks
CSS. I think it's popular because it has a beautiful layout.


2022-09-30 17:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.