为什么这些div聚集在一起?

时间:2017-10-06 20:28:06

标签: html css twitter-bootstrap

我有这些div,我想在他们的容器中以4乘6格对齐。我有第一行的代码:

    <div class="container-fluid">
        <div class="swb col-xl-6 col-lg-6 col-md-6 col-sm-6 col-xs-6">
            <div class="row">
                <div class="swb-button col-xs-3">
                    <p class="swb-button-name">1</p>
                </div>
                <div class="swb-button col-xs-3">
                    <p class="swb-button-name">2</p>
                </div>
                <div class="swb-button col-xs-3">
                    <p class="swb-button-name">3</p>
                </div>
                <div class="swb-button col-xs-3">
                    <p class="swb-button-name">4</p>
                </div>
            </div>
        </div>
    </div>

但他们像这样聚集在一起: enter image description here 由于它们的宽度为3个自举宽度,因此它们应该间隔开。 我做错了什么?

1 个答案:

答案 0 :(得分:0)

只需将col-xs-3更改为col-sm-3即可。如果您希望它们完全穿过屏幕,请删除第二个 div。最新的v4版本中不再存在 col-xs-*

&#13;
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>


 <div class="container-fluid">
    <div class="swb col-xl-6 col-lg-6 col-md-6 col-sm-6 col-xs-6">
        <div class="row">
            <div class="swb-button col-sm-3">
                <p class="swb-button-name">1</p>
            </div>
            <div class="swb-button col-sm-3">
                <p class="swb-button-name">2</p>
            </div>
            <div class="swb-button col-sm-3">
                <p class="swb-button-name">3</p>
            </div>
            <div class="swb-button col-sm-3">
                <p class="swb-button-name">4</p>
            </div>
        </div>
    </div>
</div>
&#13;
&#13;
&#13;