I think the standard of Bootstrap 3 and 4 is
...
-
Short answer: you do need to use container
, but you don't need to use row
.
You can put elements directly in the container
or container-fluid
. You aren't required to use the grid (.row
and .col-*
), and the container alone can be used as a container of content. Only use the grid when you need the responsive 12-unit structure.
For example, this is valid Bootstrap...
Hello World
Some other content...
From the Bootstrap docs...
"Bootstrap requires a containing element to wrap site contents and
house our grid system."
So, the purpose of container
is two-fold: 1) to "house the grid system", and 2) to "wrap site contents". However, when you do use the grid (.row
and .col-*
), a container is required to wrap the .row
.
Even the basic starter template utilizes container
without the grid.
In summary...
- You can use
.container
or .container-fluid
alone to contain elements and page content.
- If you use the grid (
.row
and .col-*
), .row
must be inside a .container
or .container-fluid
, and .col-*
must be inside a .row
.
- 热议问题