請考慮下面的代碼:CSS:顯示:inline-block的定位:絕對
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<style type="text/css">
.section {
display: block;
width: 200px;
border: 1px dashed blue;
margin-bottom: 10px;
}
.element-left,
.element-right-a,
.element-right-b {
display: inline-block;
background-color: #ccc;
vertical-align: top;
}
.element-right-a,
.element-right-b {
max-width: 100px;
}
.element-right-b {
position: absolute;
left: 100px;
}
</style>
<title>test</title>
</head>
<body>
<div class="section">
<span class="element-left">some text</span>
<span class="element-right-a">some text</span>
</div>
<div class="section">
<span class="element-left">some text</span>
<span class="element-right-a">some more text to force line wrapping</span>
</div>
<div class="section">
<span class="element-left">some text</span>
<span class="element-right-b">some text</span>
</div>
<div class="section">
<span class="element-left">some text</span>
<span class="element-right-b">some more text to force line wrapping</span>
</div>
<div class="section">
<span class="element-left">some text</span>
<span class="element-right-b">some more text to force line wrapping</span>
</div>
</body>
</html>
絕對定位的元素apparantly使得他需要其高度將容納箱「忘記」。
我需要絕對定位裏面的「部分」框中,是否有另一種解決方案呢?
在此先感謝, Geronimo的
編輯
使用表格是不是一個真正的選擇,我需要某種形式的「多層次」 /「嵌套式」佈局,其中第二山坳是總是在相同的位置:
| some text in first column | some text in 2nd column | some indented text | 2nd column | also indented | 2nd col | even more indent | 2nd column with a lot of text that | makes it wrap | text | ... | blah blah | ...
(當然的內部消除 「|」 S)
嘎,很難看出這是什麼檢查出來:) http://jsfiddle.net/Kyle_Sevenoaks/YTUnM/你想要的結果是什麼? – Kyle 2011-02-18 14:33:20