将下拉菜单标题与下拉菜单对齐

时间:2016-12-08 00:10:13

标签: html css twitter-bootstrap-3

我在网络开发方面不是很有经验,并且遇到了一些问题,形成了一个下拉菜单列表和一个标题。 我明白了:

enter image description here

我正试图得到这样的东西:

enter image description here

这是我写的代码。

@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
<div class="row" align="center" id="filtros">
                <div class="col-md-3">1. Cerca de tí
                    <div class="dropdown">
                        <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                            Todas las delegaciones
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                            <li><a href="#">Action</a>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="col-md-3">2. ITS
                    <div class="dropdown">
                        <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                            Todas las delegaciones
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                            <li><a href="#">Action</a>
                            </li>
                        </ul>
                    </div>

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

将div设为display:inline-block,这样就可以达到预期的标记

检查此代码段

&#13;
&#13;
@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
 .col-md-3 {
  display: inline-block;
}
ul {
  list-style-type: none;
}
&#13;
<div class="row" align="center" id="filtros">
  <div class="col-md-3">1. Cerca de tí
    <div class="dropdown">
      <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
        Todas las delegaciones
        <span class="caret"></span>
      </button>
      <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
        <li><a href="#">Action</a>
        </li>
      </ul>
    </div>
  </div>
  <div class="col-md-3">2. ITS
    <div class="dropdown">
      <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
        Todas las delegaciones
        <span class="caret"></span>
      </button>
      <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
        <li><a href="#">Action</a>
        </li>
      </ul>
    </div>
&#13;
&#13;
&#13;

希望这有帮助