2012-11-12 14 views
0

我有以下的CSS使我中心我頁彈力相對定位的div與內容

#mainholder { 
    position:relative; 
    margin-left:auto; 
    margin-right:auto; 
    width:1000px; 
    background-color:#FFFFFF; 
    min-height:1100px; 
    z-index:1; 
    clear:both; 
} 

裏面的#mainholder格,我有一個包含我的數據,這將增加或高度depemding下降的另一個DIV內容上。該CSS低於

#maincontentdiv { 
    position:absolute; 
    width:955px; 
    min-height:795px;  
    border-style:solid; 
    border-width:thin; 
    border-collapse:collapse; 
    left:10px; 
    top: 135px;  

} 

我遇到的問題是,雖然#maincontentdiv綿延如預期的那樣#mainholder不#maincontentdiv的內容舒展。我想知道如何解決這個問題或其他選項。

所有幫助將不勝感激 感謝

編輯

按照要求,這裏是HTML代碼

<div id="mainholder"> 
    <div id="topnavbar"> 
    <div id="navlinks"> 

    </div> 

    </div> 
    <div id="messagediv"> 

    </div> 
    <div id="maincontentdiv"> 
    <table width="100%" border="0"> 
     <tr bgcolor="#507CD1"> 
     <td width="19%">Grant ID</td> 
     <td width="61%">Grant Description</td> 
     <td width="20%">Manage</td> 
     </tr> 
     <?php 
     $select = " SELECT QUERY THAT WILL CHANGE THE LENGTH OF THE DIV DEPENDING ON RESULTS 

"; 
    $query = sqlsrv_query($conn,$select,array(),array("Scrollable"=>SQLSRV_CURSOR_STATIC))or die(print_r(sqlsrv_errors())); 
    while($row=sqlsrv_fetch_array($query)) 
    { 
     //variables 
     ?> 
     <tr> 
     <td><?php echo $variable ?></td> 
     <td><?php echo $variable ?></td> 
     <td>&nbsp;</td> 
     </tr> 
     <?php }?> 
    </table> 
    </div> 
    <br style="clear:both"/> 
</div> 
+0

請顯示相關html –

+0

嘗試在外部div添加「height:auto」。 – Narendra

+0

@NullPointer按要求添加 – MaxI

回答

1

你有position:absolute爲你內心的div。所以它的位置不會影響母公司。

#maincontentdiv { 
    position:absolute; 
    width:955px; 
    min-height:795px;  
    border-style:solid; 
    border-width:thin; 
    border-collapse:collapse; 
    left:10px; 
    top: 135px;  

} 

改變這

#maincontentdiv { 
    position:relative; 
    width:955px; 
    min-height:795px;  
    border-style:solid; 
    border-width:thin; 
    border-collapse:collapse; 
    margin-left:10px; 
    margin-top: 135px;  
} 

讓我知道,如果你仍然有問題。

+0

它可以工作到某一點。外部div伸展但不完全。我margn左:10px和頁邊距:135px似乎隱藏我的maincontentdiv和扭曲我的網頁。將它們更改爲left和top會產生首先描述的效果:外部div不會完全拉伸 – MaxI

+0

爲內部div添加margin-bottom或bottom。那麼它總會保持較低的差距。 – Narendra

+0

謝謝先生。利潤率底部做了訣竅。我添加了頂部:110px;和margin-bottom:110px;它解決了。即使在IE中也可以工作 – MaxI