折叠时,Bootstrap btn-group下拉列表在导航栏中不起作用

时间:2015-07-09 21:31:14

标签: css twitter-bootstrap

基本上我正在尝试将bootstrap导航栏转换为工具栏。在那个工具栏上,我添加了一些带有下拉列表的btn-groups,在媒体查询崩溃之前工作正常。一旦它被折叠,下拉菜单就无法看到,虽然元素在那里并且它会投射阴影,如果它在那里。如何在崩溃后显示这些下降?

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> INDEX </title>

    <link href="bootstrap/css/bootstrap.css" rel="stylesheet">
    <link href="mycss/style.css" rel="stylesheet">

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript" src="datepicker/js/bootstrap-datepicker.js"></script>

  </head>
  <body>
    <nav class="navbar navbar-footer">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#footNav"aria-expanded="false">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="#">Tool Bar</a>
      </div>

      <div class="collapse navbar-collapse" id="footNav">

               <!-- 1st btn-group (No Dropdown) -->

        <div class="btn-group" role="group" aria-label="..." style="margin-right: 7px">
          <button type="button" class="btn btn-default">Yesterday</button>
          <button type="button" class="btn btn-default">Today</button>
          <button type="button" class="btn btn-default">Tomorrow</button>
        </div>

        <!-- 2st btn-group doesn't work after collapse -->

        <div class="btn-group" role="group" aria-label="..." style="margin-right: 7px">
          <div class="btn-group dropup" role="group">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              Past
              <span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
              <li><a href="#">Past</a></li>
              <li><a href="#">This</a></li>
              <li><a href="#">Next</a></li>
            </ul>
          </div>
          <button type="button" class="btn btn-default">W</button>
          <button type="button" class="btn btn-default">M</button>
          <button type="button" class="btn btn-default">3M</button>
          <button type="button" class="btn btn-default">Y</button>
        </div>

              <!-- 3rd btn-group doesn't work after collapse -->

        <div class="dropup">
          <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            Date Range
            <span class="caret"></span>
          </button>
          <ul class="dropdown-menu" aria-labelledby="dropdownMenu2">

              <div class="input-group" style="padding-bottom: 4px;">
                  <span class="input-group-addon" >From:</span>
                  <input class="datepicker" style="height: 30px; width:120px; font-size: 18px; padding:10px;" name="startDate">
              </div>        

              <div class="input-group">
                  <span class="input-group-addon"  >To:</span>
                  <input class="datepicker2" style="height: 30px; width:120px; font-size: 18px; padding:10px;" name="endDate">
              </div>
          </ul>
        </div>
      </div>        
    </nav>
  </body>
</html>

我使用标准引导程序,但css更改除外

/*Calendar tool Bar*/
.navbar {
  border-radius: 0px;
}

.dropup{
    display: inline-block;
}

.dropdown-menu .input-group .input-group-addon:first-child {
    width: 63px;
}
.dropdown-menu {
    padding: 4px 4px 4px 4px;
    min-width: 30px;
}
.navbar-footer {
    background-color: #f8f8f8;
    border-color: #e7e7e7;
    position: fixed;
    bottom: 0px;
    width: 100%;
    margin-bottom: 0px;
    vertical-align: middle;
}
.navbar-footer .navbar-toggle:hover,
.navbar-footer .navbar-toggle:focus {
    background-color: #ddd;
}
.navbar-footer .navbar-toggle {
    border-color: #ddd;
}
.navbar-footer .navbar-toggle .icon-bar {
    background-color: #888;
}
button {
    margin-top: 8px;
}

1 个答案:

答案 0 :(得分:2)

你只需要覆盖bootstrap .navbar-collapse.in类,即使它垂直溢出也能看到它。

.navbar-collapse.in {
    overflow-y: visible;
}

工作example