新手问题 Bootstrap 的下拉按钮如何自适应外层 div 的宽度?

baypm2014 · October 21, 2014 · Last by mouse_lin replied at October 21, 2014 · 9021 hits

view 层代码如下:

<div class="col-md-2" style="background: #eee,; padding: 0">
  <div class="btn-group">
    <button type="button" class="btn btn-default">下拉按钮</button>
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
      <span class="caret"></span>
      <span class="sr-only">切换下拉菜单</span>
    </button>
    <ul class="dropdown-menu" role="menu">
      <li>a1</li>
    </ul>
  </div>
</div>

好,现在问题来了,如何让下拉按钮的宽度和外层 div 里设置的宽度 (col-md-2) 一致? 先谢过大家了,刚接触 bootstrap,问题幼稚请见谅了。

.dropdown-menu 有 min-width: 160px 的,只要把 min-width 设置为根据 .btn-group 宽度,然后.btn-group width: 100%,就好了

.dropdown-menu{
  min-width: inherit;
}

.btn-group{
  width: 100%;
}
You need to Sign in before reply, if you don't have an account, please Sign up first.