2013-04-08 54 views
0

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

样的想法:

<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我需要的页面的其余部分向下移动,以适应新的评论。让我知道你是否需要任何特定的代码。

回答

2

尝试在你的CSS规则与

min-height: 730px; 

更换

height: 730px; 

。它将在内容添加到内容时缩放.blogPost。它假设#commentsHolder也相对定位。

你也不想增加与重复id属性(commentsHolder)元素。

+0

感谢您的回复,非常简单的修复工作非常精美!此外,'id'属性在我的实际代码中没有重复,这只是一个复制粘贴错误。 – Colin747 2013-04-08 13:55:33