我對CSS並不擅長,但我想創建兩個選擇列表,並使用它們之間的按鈕面板來控制選定項目的來回移動。我希望它看起來像這樣:嵌入式div在包含塊輸入按鈕時的行爲類似於塊
+----------------------+-+ +----------------------+-+
| | | ___ | | |
| | | |_>_| | | |
| | | ___ | | |
| | | |_<_| | | |
| | | | | |
|______________________|_| |______________________|_|
我有以下HTML:
<div id='recipientSelection'>
<div class='clientsBox'>
<select id='allClients' size='5'>
<option>dfsdfs</option>
<option>sdfsdfds</option>
<option>fsdfsdfsdfsdf</option>
<option>dsf dsfsdfsdf</option>
<option>afaf</option>
<option>t</option>
<option>sdgfhgsfh</option>
</select>
</div>
<div id='clientButtons'>
<input type='button' id='appendButton' value='>' />
<input type='button' id='removeButton' value='<' />
</div>
<div class='clientsBox'>
<select id='chosenClients' size='5'>
<option>dfsdfs</option>
<option>sdfsdfds</option>
<option>fsdfsdfsdfsdf</option>
<option>dsf dsfsdfsdf</option>
<option>afaf</option>
<option>t</option>
<option>sdgfhgsfh</option>
</select>
</div>
</div>
下面CSS:
div#recipientSelection {
margin-left: 50px;
width: 90%;
}
select#allClients {
width: 25%;
}
select#chosenClients {
width: 25%;
}
div.clientsBox {
display: inline;
}
div#clientButtons {
display: inline;
width: 15%;
}
input#appendButton {
display: block;
}
input#removeButton {
display: block;
}
如果我使按鈕塊元素,包含其div開始表現得像塊元素一樣。我希望按鈕是相對於彼此的塊元素,但我希望按鈕面板與選擇內聯。我懷疑這裏有些重要的東西我不明白。幫幫我?
您需要'float'了'div'叫什麼。在'div's上應用'float:left'應該達到你要找的效果。 – 2010-08-25 14:19:39