Html Bootstrap 中的偏移列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41625910/
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-08-29 14:15:00  来源:igfitidea点击:

Offset columns in Bootstrap

htmltwitter-bootstrapoffset

提问by sumguy

This is the idea of what I want to do:

这是我想做的事情的想法:

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-2"></div>
        <div class="col-sm-4"></div>
        <div class="col-sm-4"></div>
        <div class="col-sm-2"></div>
    </div>
</div>

How would it work using offset?

使用偏移量如何工作?

回答by Luiz Henrique

The offset works like a blank column that will stay before your column. For example, if you want a column that will have half of the size of the screen and will be exactly in the middle, you will have to do:

偏移量就像一个空白列,将保留在您的列之前。例如,如果您想要一列只有屏幕大小的一半并且正好位于中间,则必须执行以下操作:

<div class="col-sm-6 col-sm-offset-3"></div>

A full row has 12 columns. This way you will have 6 columns (half of the row) and a offset of 3 columns. It will be exactly in the middle of the screen.

一整行有 12 列。这样,您将有 6 列(行的一半)和 3 列的偏移量。它将正好位于屏幕的中间。

Take a look on Bootstrapdocumentation.

查看Bootstrap文档。

回答by Zim

In Bootstrap 3,like this..

Bootstrap 3 中,像这样..

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-4 col-sm-offset-2"></div>
        <div class="col-sm-4"></div>
    </div>
</div>

http://www.codeply.com/go/7wofwfzrH3

http://www.codeply.com/go/7wofwfzrH3

In Bootstrap 4, like this..

Bootstrap 4 中,像这样..

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-4 offset-sm-2"></div>
        <div class="col-sm-4"></div>
    </div>
</div>

https://www.codeply.com/go/t5DTGwero8

https://www.codeply.com/go/t5DTGwero8

回答by demsley

The above doesn't work for me as I thinkthe bootstrap classes have changed slightly.

以上对我不起作用,因为我认为引导程序类略有变化。

<div class="col-md-4 offset-md-2">

Does work for me.

对我有用。

Hope this helps

希望这可以帮助

Dave

戴夫