html - 圆形缩略图对齐

标签 html css twitter-bootstrap

我实现了一种圆形缩略图,但问题是当我的圆形缩略图转到下一行/行时,如果缩略图描述的文本长度不同,它就会开始出现白色间隙。

html:

<h2 class="border-bottom">Services</h2>

    <div class="row">
      <article class="service col-sm-3">
      <img class="img-circle" src="images/service-1.png" alt="Icon">
      <h3>CONSULTANCY</h3>
      <p class="service-text">Understanding and addressing organizations’ needs</p>
    </article>

    <article class="service col-sm-3">
      <img class="img-circle" src="images/service-2.png" alt="Icon">
      <h3>IMPLEMENTATION</h3>
      <p class="service-text">Identifying, Identifying, Identifying, training and supporting</p>
    </article>
....

enter image description here

最佳答案

当您将不同高度的 float 元素换行到下一行时,就会发生这种情况。您需要做的就是制作一个新的 .row对于每一行,或添加 <div class="clearfix"></div>在每一整行之后。不需要 JS,bootstap 可以自行处理。

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

<div class="row">
    <article class="service col-xs-3">
      <img class="img-circle" src="https://placekitten.com/100/100" alt="Icon">
      <h5>CONSULTANCY</h5>
      <p class="service-text">Understanding and addressing organizations’ needs</p>
    </article>

    <article class="service col-xs-3">
      <img class="img-circle" src="https://placekitten.com/100/100" alt="Icon">
      <h5>IMPLEMENTATION</h5>
      <p class="service-text">Identifying, Identifying, Identifying, training and supporting</p>
    </article>
    <article class="service col-xs-3">
      <img class="img-circle" src="https://placekitten.com/100/100" alt="Icon">
      <h5>Foo</h5>
      <p class="service-text">short text</p>
    </article>

    <article class="service col-xs-3">
      <img class="img-circle" src="https://placekitten.com/100/100" alt="Icon">
      <h5>Bar</h5>
      <p class="service-text">short text</p>
    </article>
    
    <div class="clearfix"></div>
    
    <article class="service col-xs-3">
      <img class="img-circle" src="https://placekitten.com/100/100" alt="Icon">
      <h5>CONSULTANCY</h5>
      <p class="service-text">Understanding and addressing organizations’ needs</p>
    </article>

    <article class="service col-xs-3">
      <img class="img-circle" src="https://placekitten.com/100/100" alt="Icon">
      <h5>IMPLEMENTATION</h5>
      <p class="service-text">Identifying, Identifying, Identifying, training and supporting</p>
    </article>
    <article class="service col-xs-3">
      <img class="img-circle" src="https://placekitten.com/100/100" alt="Icon">
      <h5>CONSULTANCY</h5>
      <p class="service-text">Understanding and addressing organizations’ needs</p>
    </article>

    <article class="service col-xs-3">
      <img class="img-circle" src="https://placekitten.com/100/100" alt="Icon">
      <h5>IMPLEMENTATION</h5>
      <p class="service-text">Identifying, Identifying, Identifying, training and supporting</p>
    </article>
</div>

关于html - 圆形缩略图对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34104465/

相关文章:

html - 在页面 CSS 上定位元素

html - 带有溢出子项的可滚动父控件,以在表格中显示工具提示

jquery - 根据内容 Bootstrap 井大小

html - Bootstrap 行消失

javascript - 当元素失去焦点时,如何在 contenteditable 元素中保持选中的文本?

html - 如何从 ASP.NET AJAX 控件工具包中的 HTML 编辑器获取纯文本?

javascript - 让 DOM 模板在 VueJS 2.0 中工作的确切要求是什么?

html - 我的导航下拉菜单上的图标消失了

html - 覆盖 CSS 高度 :auto and width:auto and use HTML attribute instead?

javascript - bootstrap 2.1 模式自动对焦不起作用