Bootstrap - should each row have container as immediate parent? [duplicate]

旧巷老猫 提交于 2020-01-30 03:22:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!