问题
I know column should have row as immediate parent (or, to be precise, rows should have only columns as ther immediate children) but does row must have container/container-fluid as immediate parent?
I couldn't find mentioning it in docs and i've seen examples of both: where rows do and don't have their respective containers.
回答1:
It depends on the Bootstrap version, and how you want the content aligned, but generally containers are required...
Version 3.x
"Rows must be placed within a .container (fixed-width) or .container-fluid (full-width) for proper alignment and padding."
Version 4.x
"Containers are the most basic layout element in Bootstrap and are required when using our default grid system."
The top level element of the grid system is the .row, and therefore row's should be the immediate child of a container. Bootstrap 4 is more flexible in that rows & columns can be created without gutters, and the spacing utils can be used to adjust padding and margins.
回答2:
It is not essential that a row has a container as immediate parent as in some cases it is not possible to have it as immediate parent. But to be consistent with your project you should always have container as some parent to the row as you may experience alignment and padding problems without it.
来源:https://stackoverflow.com/questions/46274948/bootstrap-should-each-row-have-container-as-immediate-parent