2013-04-08 56 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