正如你可以在底部代码中看到的那样,我创建li来使列表代替html标记中的选项。但在外观上我得到了不好的东西。使用li代替选择
- 如何使li宽度与底宽相同。我在CSS中增加了宽度值。 100%的值使li比底部更宽。
- 汤姆怎么把里面的号码和号码浮在右边。我可以添加类上拉rigt使它在正确的位置,但它做出比在左边的位置文本插入记号更高的(我想使他们在同一个中间垂直位置)
.instead-option {
\t \t z-index:999;
\t \t position: absolute;
\t \t margin: 0;
\t \t max-height:300px;
\t \t background: #ffffff;
\t \t border-radius:4px;
\t \t border:1px solid #dddddd;
\t \t width:100%;
\t \t overflow:auto;
\t }
\t .instead-option > li {
\t \t width:100%;
\t \t background: #eee;
\t \t line-height: 25px;
\t \t font-size: 14px;
\t \t padding: 0 10px;
\t \t cursor: pointer;
\t }
\t .instead-option > li > a{
\t \t display: flex;
\t \t width: 100%;
\t }
\t .instead-option > li:nth-child(odd) {
\t \t background-color: #ffffff;
\t }
\t .instead-option > li:nth-child(even) {
\t \t background-color: #e5e5e5;
\t }
\t .instead-option > li:hover {
\t \t background: #aaa;
\t }
\t .instead-option > li > a{
\t \t color:#232323;
\t \t text-decoration:none;
\t }
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="container">
\t <div class="row">
\t \t <div class="col-sm-12">
\t \t \t <button type="button" class="form-control text-left nominal">Pilih nominal<span class="caret caret-right"></span></button>
\t \t \t <ul class="instead-option list-unstyled">
\t \t \t \t <li><a href="#">English <span class="text-primary pull-right">10000</span></a></li>
\t \t \t \t <li><a href="#">Deutsch <span class="text-primary pull-right">50000</span></a></li>
\t \t \t </ul>
\t \t </div>
\t </div>
</div>
@ digilac3谢谢你...你救了我的一天。所有答案都可以解决我的问题。但如何与数量(10000和50000)。我想要像插入号码一样的位置。在右边 –
@Dedi用'display:block;'替换'display:flex;'''.instead-option> li> a' – digitalac3
@ digilac3非常感谢。愿你的良善从神得到最好的奖赏 –