Differences between container, row and span in Bootstrap

后端 未结 3 1808
醉酒成梦
醉酒成梦 2020-12-13 06:18

While using Twitter Bootstrap, should I nest a row div within a container div and put all my span divs within the nested row? Is that the best practice?

What if I pu

3条回答
  •  孤城傲影
    2020-12-13 06:54

    In general you would use container > row > span

    I can't think of an example where the the other 2 options you ask about would break anything, but they may not give you the results you want.

    Wrapping everything in the conatiner div will manage the width of the page and side padding. Using the row div will ensure that your spans are layed out the way you want. For example imagine 2 rows that each have just have a single span4. If you don't use the row div the 2 span4s will float one next to the other instead of being stacked vertically.

    There are many cases where you will have nested containers in a Bootstrap layout, the first one you will likely come across is in the nav bar, and once you start using fluid Bootstrap layouts you will see that container divs are not always 940px, but if you stick to the container > row > span arrangement it will save you some grief, especially if you are just starting.

    Good luck!

提交回复
热议问题