Mhd*_*Mhd 5 html css twitter-bootstrap
我已将 dropdwon 定义为 Fellow:
<div class="form-group">
<select class="form-control">
<option>small option</option>
<option>mediummmmmmmmmmmmmmmmmmmm option</option>
<option>large eeeeeeeeeeeeeeeeeeeeee eeeeeeeeeeeeeee eeeeeeeeeeeee eeee option</option>
</select>
</div>
Run Code Online (Sandbox Code Playgroud)
我想将select宽度更改为容器宽度和option文本宽度的最小值。如果option文本大于div容器,则截断选项的文本并将省略号放在末尾。所以option留在容器内。还select必须是响应式的,调整窗口大小时,select应更新宽度以适应新的窗口宽度。
如何使用 bootstrap CSS 实现这一点?
Ste*_*hen -1
.dropdown{
width:150px;
border: 1px solid #cfcfcf;
height: auto;
border-radius: 5px;
padding:3px 4px 4px;
position: relative;
z-index: 0;
overflow:hidden;
}
.dropdown select{
border: none;
background-color: transparent;
outline: none;
padding: 0;
width:150px;
/* background: url(http://i57.tinypic.com/nnmgpy_th.png) no-repeat right; */
/* background-position: 55%; */
}
/* not 100% sure this next option rule is needed */
.dropdown option {
width:150px
}
/* this places an arbitrary element inside the dropdown but before it's children elements */
/* We use it to cover half the select box as well as display the custom arrow */Run Code Online (Sandbox Code Playgroud)
<div class="dropdown">
<select>
<option value="">Some Text</option>
<option value="">Some More Text2</option>
<option value="">Some More More More Longer Text</option>
</select>
</div>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9898 次 |
| 最近记录: |