0

在我的网站中有多个博客文章,用户可以在这些博客文章的底部添加评论。当用户添加评论时,评论下方的内容不会向下移动以适应它,因此评论被放置在其他内容之上。我该如何解决这个问题?

代码示例思想:

<div class=blogPost>
  <article>
    <p>Blog Entry</p>
    <div id="commentsHolder">
    </div>
  </article>
  <div class="commentForm">
    <?php showing form if user is logged in ?>
  </div>
</div>
<div class=blogPost>
  <article>
    <p>Blog Entry</p>
    <div id="commentsHolder">
    </div>
  </article>
  <div class="commentForm">
    <?php showing form if user is logged in ?>
  </div>
</div>
...etc...

CSS:

.blogPost {
  position: relative;
  height: 730px;
  width: 950px;
  border: 1px solid;
  border-color: #A62121;
  border-radius: 25px;
  padding: 5px;
}

添加评论后,commentsHolder我需要将页面的其余部分向下移动以容纳新评论。如果您需要我拥有的任何特定代码,请告诉我。

4

1 回答 1

2

尝试更换

height: 730px;

min-height: 730px;

在您的 CSS 规则中。它将.blogPost随着内容的添加而缩放。它假设#commentsHolder也是相对定位的。

您也不想添加具有重复id属性 (commentsHolder) 的元素。

于 2013-04-08T13:50:40.050 回答