自舉下拉菜單docs,樣式總是應用到button
元素是這樣的:
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown button
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
但collection_select
是要給你select
,像這樣:
<select name="post[author_id]">
<option value="">Please select</option>
<option value="1" selected="selected">D. Heinemeier Hansson</option>
<option value="2">D. Thomas</option>
<option value="3">M. Clark</option>
</select>
我m猜測HTML看起來像這樣:
<select ... class = "btn btn-secondary dropdown-toggle">
我想Bootstrap不知道該怎麼做。
在回答這個問題時留下這個問題,但也要考慮@jvillian的答案;您可能不希望將選擇下拉列表設置爲按鈕。 – GoGoCarl
感謝它的工作! – Xavi