Twitter Bootstrap Containers

拜拜、爱过 提交于 2019-11-30 22:03:34

问题


Ive been using bootstrap for a few months and am looking to clarify something as part of best practices.

My question is do I create a container for each row or just one big container for the whole page.

Example1 (Closed Containers)

<div class="container">
    <div class="row">
        <div class="span8 offest2">
            <h1>Content</h1>
        </div>
    </div>
</div>


<div class="container">
    <div class="row">
        <div class="span8 offest2">
            <h1>More Content</h1>
        </div>
    </div>
</div>

Example 2 (1 large container)

<div class="container">

    <div class="row">
        <div class="span8 offest2">
            <h1>Content</h1>
        </div>
    </div>

    <div class="row">
        <div class="span8 offest2">
            <h1>Content</h1>
        </div>
    </div>

</div>

Any help appreciated, just dont want to get into bad habits early on


回答1:


I would recommend the second example. In the first you have duplicate code wich makes no real sense. Always think about the principle "Don't repeat yourself".




回答2:


Multiple rows can logically be part of the same grid, like rows in a table. The .container represents one grid. So Example 2 would be the way to go.



来源:https://stackoverflow.com/questions/11203614/twitter-bootstrap-containers

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