javascript - for 在 <div class ='col-sm-4' > 上循环内容,但是当内容太长时 for 循环会跳过一个地方

标签 javascript jquery html css twitter-bootstrap-3

我 for 循环我的内容,其中有一张图片和该图片下方的一个标题。

<div class="row">
<article>
  {% for news in newsInCat %}
  <div class='col-sm-4'>

    <div class="content">
    <figure class="story-image">
      <a href='{{news.get_absolute_url }}'><img src="{{news.get_image_url}}"  class="img-rounded" alt="Cinque Terre" width="360" height="267"></a>
    </figure>
      <div id="forever "style="margin-bottom:30px;">
      <a href='{{news.get_absolute_url }}' style="text-decoration:none; color:#282E5C;"><h4 style="font-size: 18px;
    font-weight: 400;">{{news.title}}</h4></a>
  </div>
        </div>
  </div>
  {% endfor %}
</article>
</div>

但是当{{news.title}} 变得超过一行时,标题下面的内容会破坏它的形式。我会用图片显示问题。 enter image description here

标题很长,需要两行。现在下面的内容被移到较低的级别 enter image description here

有人可以帮我解决这个问题吗?

最佳答案

为循环元素提供固定高度

article .col-sm-4 {
height:300px;//change this
}

关于javascript - for 在 <div class ='col-sm-4' > 上循环内容,但是当内容太长时 for 循环会跳过一个地方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36491414/

相关文章:

javascript - React - 从 API 收到 401 响应后保留表单信息

jquery - CSS3 TranslateX 相对于当前位置,如 jQuery animate

javascript - JQuery Clone - 在两个元素上触发相同的事件

php - DOMNodeList::getAttribute 未定义

html - 在 HTML5 或 svg 文件中缩放 SVG

javascript - 将增量计数器连接到 json 响应循环内的数组选择器的末尾

javascript - 如何从正则表达式中的特定位置删除或替换字母

javascript - 是否有任何解决方案可以显示从弹出窗口到选择字段的选定记录

php - 单击时,在更新 MySQL 数据库时隐藏 DIV

css - 流体布局的 Div 定位