Twitter 引导容器

2022-01-24 00:00:00 containers html twitter-bootstrap

我已经使用 bootstrap 几个月了,我希望澄清一些作为最佳实践的一部分.

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.

示例 1(封闭容器)

<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>

示例 2(1 个大容器)

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

推荐答案

我会推荐第二个例子.首先,您有重复的代码,这没有任何意义.始终考虑不要重复自己"的原则.

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".

相关文章