为什么 bootstrap 网格不正确地堆叠这些元素?
Why does bootstrap grid improperly stack these elements?
我的网格中的第三个元素没有向左倾斜,而是向右倾斜。我相信这是因为列的高度不同。我不能简单地附加 2 行,因为代码的构建方式应该显示为 1x4、2x2,然后是 4x1。我不想通过 javascript 或 css 根据屏幕大小显示和隐藏行,因为我宁愿让网格系统按其应有的方式工作。附上我的代码示例,供参考。
<div class="container-fluid" style="background-color: ">
<div class="col-md-3 col-sm-6" style="background-color: red;">
<div class="feature-box">
<div class="feature-item"></div>
<p class="sub-title">Better Customer Relationships</p>
<p class="text">Personalized emails connect you with your customers.</p>
</div>
</div>
<div class="col-md-3 col-sm-6" style="background-color: red;">
<div class="feature-box">
<div class="feature-item"></div>
<p class="sub-title">Set it and Forget It</p>
<p class="text">Set up a Jaynote campaign once, and automatically engage with every customer.</p>
</div>
</div>
<div class="col-md-3 col-sm-6" style="background-color: red;">
<div class="feature-box">
<div class="feature-item"></div>
<p class="sub-title">Easy to Use</p>
<p class="text">Simple management panel shows you exactly what to do.</p>
</div>
</div>
<div class="col-md-3 col-sm-6" style="background-color: red;">
<div class="feature-box">
<div class="feature-item"></div>
<p class="sub-title">Guaranteed Results</p>
<p class="text">90 Day money-back guarantee if you are not completely satisfied with your results.</p>
</div>
</div>
</div>
您是否尝试过每 2 个 col-sm-6
(整行 12 列)元素应用一个 .clearfix
:
<div class="col-md-3 col-sm-6" style="background-color: red;">
<div class="feature-box">
<div class="feature-item"></div>
<p class="sub-title">Better Customer Relationships</p>
<p class="text">Personalized emails connect you with your customers.</p>
</div>
</div>
<div class="col-md-3 col-sm-6" style="background-color: red;">
<div class="feature-box">
<div class="feature-item"></div>
<p class="sub-title">Set it and Forget It</p>
<p class="text">Set up a Jaynote campaign once, and automatically engage with every customer.</p>
</div>
</div>
<!-- apply clearfix -->
<div class="clearfix"></div>
我的网格中的第三个元素没有向左倾斜,而是向右倾斜。我相信这是因为列的高度不同。我不能简单地附加 2 行,因为代码的构建方式应该显示为 1x4、2x2,然后是 4x1。我不想通过 javascript 或 css 根据屏幕大小显示和隐藏行,因为我宁愿让网格系统按其应有的方式工作。附上我的代码示例,供参考。
<div class="container-fluid" style="background-color: ">
<div class="col-md-3 col-sm-6" style="background-color: red;">
<div class="feature-box">
<div class="feature-item"></div>
<p class="sub-title">Better Customer Relationships</p>
<p class="text">Personalized emails connect you with your customers.</p>
</div>
</div>
<div class="col-md-3 col-sm-6" style="background-color: red;">
<div class="feature-box">
<div class="feature-item"></div>
<p class="sub-title">Set it and Forget It</p>
<p class="text">Set up a Jaynote campaign once, and automatically engage with every customer.</p>
</div>
</div>
<div class="col-md-3 col-sm-6" style="background-color: red;">
<div class="feature-box">
<div class="feature-item"></div>
<p class="sub-title">Easy to Use</p>
<p class="text">Simple management panel shows you exactly what to do.</p>
</div>
</div>
<div class="col-md-3 col-sm-6" style="background-color: red;">
<div class="feature-box">
<div class="feature-item"></div>
<p class="sub-title">Guaranteed Results</p>
<p class="text">90 Day money-back guarantee if you are not completely satisfied with your results.</p>
</div>
</div>
</div>
您是否尝试过每 2 个 col-sm-6
(整行 12 列)元素应用一个 .clearfix
:
<div class="col-md-3 col-sm-6" style="background-color: red;">
<div class="feature-box">
<div class="feature-item"></div>
<p class="sub-title">Better Customer Relationships</p>
<p class="text">Personalized emails connect you with your customers.</p>
</div>
</div>
<div class="col-md-3 col-sm-6" style="background-color: red;">
<div class="feature-box">
<div class="feature-item"></div>
<p class="sub-title">Set it and Forget It</p>
<p class="text">Set up a Jaynote campaign once, and automatically engage with every customer.</p>
</div>
</div>
<!-- apply clearfix -->
<div class="clearfix"></div>