0

我的问题是无法识别内容的高度,这导致正文小于内容,从而导致更多问题。

HTML:

<section id="contentbox">   
  {% for post in site.posts %}
  <article>
    <h2>
      <a href="{{ post.url }}">
        {{ post.title }}
      </a>
    </h2>
    <time datetime="{{ post.date | date: "%Y-%m-%d" }}">{{ post.date | date_to_long_string }}</time>
    <p>
      {{ post.caption }}
    </p>
  </article>
{% endfor %}
</section>

CSS:

#contentbox {
      height: 100%;
}
article {
  width: 45%;
  float: left;
  height: 120px;
  padding: 2px 0 0 2px;
}

我列出了一堆文章,但该部分保持高度:0

4

1 回答 1

1

在浮动元素之后放置一个明确的修复元素。例如:<div style="clear: both;"></div>

这是一个非常普遍的问题。

于 2019-03-11T12:42:07.967 回答