网格系统下的推送和偏移有什么区别?

时间:2014-04-01 17:28:17

标签: css twitter-bootstrap user-interface twitter-bootstrap-3

我试图了解Bootstrap网格中推送和偏移之间的区别。例如,下面两行之间的唯一区别是每行中的第三列。一个使用推,另一个使用偏移。但是,它们都呈现完全相同。

<div class="row">
    <div class="col-md-2">
        <h2>Column 1</h2>
        <p>
            This is text for column 1
        </p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more &raquo;</a></p>
    </div>
    <div class="col-md-2">
        <h2>Column 2</h2>
        <p>This is text for column 2</p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more &raquo;</a></p>
    </div>
    <div class="col-md-2 col-md-push-6">
        <h2>Column 3</h2>
        <p>This is text for column 3</p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301867">Learn more &raquo;</a></p>
    </div>
</div>

<div class="row">
    <div class="col-md-2">
        <h2>Column 1</h2>
        <p>
            This is text for column 1
        </p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more &raquo;</a></p>
    </div>
    <div class="col-md-2">
        <h2>Column 2</h2>
        <p>This is text for column 2</p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more &raquo;</a></p>
    </div>
    <div class="col-md-2 col-md-offset-6">
        <h2>Column 3</h2>
        <p>This is text for column 3</p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301867">Learn more &raquo;</a></p>
    </div>
</div>

3 个答案:

答案 0 :(得分:89)

由于偏移量使用margin-left,因此推送使用left

  • 偏移将强制相邻列移动
  • push(和pull)将与其他列重叠

以下是一个直观的例子:http://www.bootply.com/126557

在您的示例中,没有列&#39;碰撞&#39;。推送和偏移看起来相同,因为相邻的列没有受到影响。

答案 1 :(得分:6)

.col-md-offset-*:将左边距增加*个类

.col-md-push-* / .col-md-pull-*:将更改*类显示网格列的顺序。 Pull会将列发送到左侧,而push会将其发送到右侧。

答案 2 :(得分:1)

引导程序中的偏移将偏移列的左侧,从而将其移过或“#34;偏移”#34;在右边的东西。使用&#34;偏移&#34;你只能将项目偏移到右边。对于推拉,你可以把东西拉到'左边或右边'#34;或者你可以推动与拉动相反的东西。推动或拉动物品主要用于柱子订购。

相关问题