CSS Bootstrap:边距的类?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18170762/
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
Bootstrap: Class for margin-right?
提问by Prem Ananth C
I believe to provide standard margin-left we can use class "Offset" in bootstrap. At the same time what is the class that can be used to provide standard margin-right? example:
我相信提供标准的margin-left,我们可以在引导程序中使用“Offset”类。同时可以提供标准margin-right的类是什么?例子:
<div class="row-fluid">
<div class="offset2 span8"></div>
</div>
for some reason I need to give margin-right equivalent to offset2. Some solution will be of great help. Thank you.
出于某种原因,我需要给予相当于 offset2 的 margin-right。一些解决方案将有很大帮助。谢谢你。
回答by Joe Conlin
There is no equivalent class to offset-x for margin-right and for good reason, it is not needed. Think of it this way, if you need a 6 column div that is offset both right and left 3 columns, you would use:
对于 margin-right 没有与 offset-x 等效的类,并且有充分的理由,不需要它。可以这样想,如果您需要一个 6 列 div,该 div 左右 3 列都偏移,您可以使用:
<div class="row">
<div class="span6 offset3">Your content...</div>
</div>
Also, if you have a 6 column div that needs to only be offset 2 columns BUT, the offset should be 2 columns on the right, the code would be:
此外,如果您有一个 6 列的 div 只需要偏移 2 列,则偏移量应该是右侧的 2 列,代码将是:
<div class="row">
<div class="span6 offset4">Your content...</div>
</div>
Keep in mind you are always working in 12 columns (unless changes in variables.less) so you can use span-x AND offset-x to achieve position desired. If you are looking to tweak additional pixels, add an additional class(or ID) to your content container inside of your span. For example:
请记住,您始终在 12 列中工作(除非 variables.less 发生变化),因此您可以使用 span-x AND offset-x 来实现所需的位置。如果您想调整额外的像素,请向您的跨度内的内容容器添加一个额外的类(或 ID)。例如:
<div class="row">
<div class="span6 offset4">
<div class="tweaked-margin">Your content...</div>
</div>
</div>
The CSS:
CSS:
.tweaked-margin {
margin-right: 4px; // or whatever you need
}