css - 当文本很大时 Bootstrap 网格中断

标签 css twitter-bootstrap grid

这个问题我遇到过好几次了,一直找不到合适的解决办法。 基本上我有一个 Bootstrap 网格,其中有 2 列与文本并排(可以说是 4 行)。 如果网格中的其中一项具有大文本,则网格会中断并且不会在正确位置显示以下元素。

Here is the example .您可以在电话支持下看到它中断(如果您在 col-md > 屏幕中看到它)

我的解决方案是将元素的最小高度设置为较大文本的最大高度,这样就可以了,但这不是最佳解决方案。 有什么想法吗?

最佳答案

你可以在你的元素之后设置class clear fix

你可以在你的媒体中设置哪一个连续设置

例如

//sass file

//this code set two element in a row

.clearfix{
  &:nth-of-type(n){
    display: none;
  }

  &:nth-of-type(4n){
    display: block;
  }
}
<div class="container">
  <div class="row">
    <div class="col-sm-4">
      <a href="#">
        <img src="" alt="" />
      </a>						
    </div>
    <div class="clearfix"></div>
    <div class="col-sm-4">
      <a href="#">
        <img src="" alt="" />
      </a>
    </div>
    <div class="clearfix"></div>
    <div class="col-sm-4">											
      <a href="#">
        <img src="" alt="" />
      </a>									
    </div>
    <div class="clearfix"></div>
  </div>
</div>

关于css - 当文本很大时 Bootstrap 网格中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39220967/

相关文章:

html - 在右侧导航栏之间添加分隔线

html - 使用 twitter bootstrap 将容器设置为精确宽度

java - GXT 3 多排序网格

css - Rails WebView 中的内联 CSS

javascript - 当屏幕变宽时,视频不会全宽

asp.net 3.5 设置自定义 web 控件中控件的样式

ios - 如何绘制一个多列的 UITableView?

css - 在 div 的右侧对齐动态创建的图像

html - 在 Bootstrap 4 中更改屏幕宽度时如何更改导航栏的颜色

arrays - 查找数组元素索引的更好方法?