2014-03-27 94 views
0

我是triyng以獲得帶有id名稱結果的div標籤,它將是動態的div標籤數據的相同大小。我應該如何處理這個問題?根據另一個動態的div標籤的數據展開div標籤

感謝

<!DOCTYPE html> 
<html> 
<head> 
<style> 
#main 
{ 
border:5px solid black; 
float:left; 
} 

#result 
{ 
border:5px solid red; 
float:left; 
width: 200px; 
} 

#data 
{ 
border:5px solid red; 
float:left; 
width: 200px; 
} 
</style> 
</head> 
<body> 

<h1>Test</h1> 

<div id="main"> 
<div id="result">Result:</div> 
<div id="data">Dynamic Data etc...blah Dynamic Data etc...blah Dynamic Data etc...blah  Dynamic Data etc...blah Dynamic Data etc...blah Dynamic Data etc...blah Dynamic Data etc...blah Dynamic Data etc...blah </div> 
</div> 
</body> 
</html> 
+0

[這個問題可能會幫助(http://stackoverflow.com/questions/14257593/how-to-change-the-height-of-a-div-dynamically-based -on-another-div-usign-css?rq = 1) – TylerH

+0

謝謝TylerH,我來看看。 – Noe

回答

0

要麼你可以使用表格佈局參見:

Demo using table

<table id="main"> 
    <tr> 
     <td id="result">Result:</td> 
     <td id="data">Dynamic Data etc...blah Dynamic Data etc...blah Dynamic Data etc...blah  Dynamic Data etc...blah Dynamic Data etc...blah Dynamic Data etc...blah Dynamic Data etc...blah Dynamic Data etc...blah </td> 
    </tr> 
</table> 

或者只是使用display: table-cell屬性爲您#data#result DIV:

Demo using display: table-cell

#data, #result 
{ 
    border:5px solid red; 
    display: table-cell; 
    width: 200px; 
}