'我试图将带有id名称结果的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 :(得分: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
div的#result
属性:
<强> Demo using display: table-cell
强>
#data, #result
{
border:5px solid red;
display: table-cell;
width: 200px;
}