twitter-bootstrap 使用 Twitter Bootstrap 向容器添加填充

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16245778/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 16:59:38  来源:igfitidea点击:

Add a padding to the container with Twitter Bootstrap

twitter-bootstrap

提问by Arnaud

Using Twitter Bootstrap, I'm looking for a way to add padding left, or margin left, to the container of the page. (expressed in units of percentage of the page)

使用 Twitter Bootstrap,我正在寻找一种向页面的容器添加向左填充或向左空白的方法。(以页面百分比为单位表示)

In fact, if I don't include bootstrap-responsive.css, the padding is quite good for me. But I would like that my website works fine on mobiles. So it is necessary to include this file, and a direct effect (why ?) is that the padding-left (or margin-left, I don't know) is less important.

事实上,如果我不包含 bootstrap-responsive.css,padding 对我来说已经相当不错了。但我希望我的网站在手机上运行良好。所以有必要包含这个文件,一个直接的影响(为什么?)是 padding-left(或 margin-left,我不知道)不太重要。

I've tried to add manually padding-left or margin-left to the container class in my own CSS, but it enlarges the width of the page and creates an horizontal scroll-bar.

我尝试在我自己的 CSS 中向容器类手动添加 padding-left 或 margin-left,但它会扩大页面的宽度并创建一个水平滚动条。

Do you know a safe way to do it, maybe using tools provided by Bootstrap ?

您知道一种安全的方法吗,也许使用 Bootstrap 提供的工具?

采纳答案by ?mer Faruk Almal?

There maybe other ways but try sth. like this:

也许还有其他方法,但请尝试…… 像这样:

<div class="container">
    <div class="row-fluid">
        <div class="span2"></div>
        <div class="span8">
            Content
        </div>
        <div class="span2"></div>
    </div>
</div>

This makes your page responsive and narrower at same time. About bootstrap fluidgridsystem.

这使您的页面同时具有响应性和更窄。关于bootstrap 流体网格系统

回答by Lijin Durairaj

<div class="container">
    <div class="row-fluid">
        <div class="col-md-offset-2 col-md-8">
            Content
        </div>
     </div>
</div>