Bootstrap下拉列表未显示在非折叠视图中

时间:2015-11-11 12:57:14

标签: jquery css twitter-bootstrap



// ADD SLIDEDOWN ANIMATION TO DROPDOWN //
$('.dropdown').on('show.bs.dropdown', function(e) {
  $(this).find('.dropdown-menu').first().stop(true, true).slideToggle();
});

// ADD SLIDEUP ANIMATION TO DROPDOWN //
$('.dropdown').on('hide.bs.dropdown', function(e) {
  $(this).find('.dropdown-menu').first().stop(true, true).slideToggle();
});

$(document).on('click', '.navbar-collapse.in', function(e) {
  if ($(e.target).is('a') && $(e.target).attr('class') != 'dropdown-toggle') {
    $(this).collapse('hide');
  }
});

* {
  font-family: 'Ubuntu', sans-serif;
}
.right-menu-wrapper {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: fixed;
}
#loading {
  width: 100%;
  height: 100%;
  background-color: #90e0b3;
  position: fixed;
  font-size: 25vh;
  line-height: 25vh;
  color: #0d8541;
  z-index: 998;
  padding-top: 33vh;
}
.container-fluid {
  vertical-align: center;
}
.navbar {
  color: black!important;
  background-image: url('../img/divbg.png');
  background-position: 0px 0px;
  background-repeat: repeat-x;
  background-color: mediumseagreen;
  z-index: 999;
  margin-bottom: 0px !important;
  position: fixed;
  width: 100%;
  border-radius: 0px;
  overflow: hidden;
}
.navbar-2nd {
  margin-bottom: 0px !important;
  background: none !important;
  overflow: hidden;
}
.navbar-brand {
  margin: 0px !important;
}

.navbar a{
  color: black!important;
}

.footer-bar {
  background-image: none !important;
  background-color: #222;
  padding: 2vh 2vw 2vh 2vw;
  height: 16vh !important;
  width: 100vw !important;
}
.footer-responsive {
  height: 100%;
}
.footer-responsive .btn {
  font-size: 1.5vh;
  margin: 0 1.5vw 0 1.5vw;
}
.footer-responsive .btn .fa {
  font-size: 10vh;
}
.footer-bar .btn-link {
  color: #FFF !important;
  padding: 0px 8px;
}
.footer-bar .btn-link:hover {
  text-decoration: none;
}
.login-btn {
  padding: 0px !important;
}
.wrapper {
  background: url('/img/bg.jpg') no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  padding: 5vh;
  padding-top: 15vh;
}
.logo-group * {
  padding: 0px !important;
}
.logo-group {
  width: 11em !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
.icon-logo,
.header-logo {
  text-shadow: 2px 2px 2px #222222;
}
h2.header-logo {
  display: inline;
  margin: 0px;
  font-weight: bold;
  font-size: 36px;
  text-transform: lowercase;
  letter-spacing: -1px;
  color: white;
  font-family: 'Ubuntu', sans-serif;
}
i.header-logo {
  font-size: 30px;
  color: white;
  text-shadow: -2px 2px 2px #222222;
  position: relative;
  top: 4px;
}
.home-video-play > span {
  font-size: 2em;
}
.home-video-play {
  background-color: mediumseagreen;
  color: white;
}
.home-video-play:hover {
  background-color: mediumseagreen;
  color: white;
}
.currentBtn {
  color: mediumseagreen;
}
.btn-default.focus {
  outline: none !important;
  background-color: #FFF !important;
  color: mediumseagreen !important;
}
h1.icon-logo {
  display: inline;
  margin: 0px;
  font-weight: bold;
  font-size: 12vw;
  text-transform: lowercase;
  letter-spacing: -3px;
  color: mediumseagreen;
  font-family: 'Ubuntu', sans-serif;
}
i.icon-logo {
  font-size: 10vw;
  color: mediumseagreen;
}
.feature-icon {
  margin-left: auto;
  margin-right: auto;
  margin-top: 3vh;
  margin-bottom: 3vh;
  line-height: 10vh;
  color: mediumseagreen;
  float: none !important;
  clear: both !important;
}
.signup-btn {
  background-color: mediumseagreen;
  color: white;
}
.signup-btn:hover {
  background-color: mediumseagreen;
  color: white;
  bottom: 0px;
}
.signup-row {
  padding-top: 5vh;
  padding-bottom: 10vh;
  background-color: white;
  color: #222222;
  min-height: 70vh;
}
.signup-row > h4 {
  margin-top: 40px;
}
.logo-row {
  padding-top: 5vh;
  padding-bottom: 10vh;
  color: white;
  min-height: 75vh;
}
.helper-signin {
  top: 20px;
}
.signup-alternatives {
  margin-top: 40px;
}
.btn-fb,
.btn-fb:hover {
  color: #3b5998;
}
.btn-gp,
.btn-gp:hover {
  color: #d34836;
}
.btn-tw,
.btn-tw:hover {
  color: #4099FF;
}
.btn-li,
.btn-li:hover {
  color: #007bb5;
}
.about-logo {
  display: inline;
  margin: 0px;
  line-height: 10vh;
  font-weight: bold;
  font-size: 8vh;
  text-transform: lowercase;
  letter-spacing: -3px;
  color: mediumseagreen;
  font-family: 'Ubuntu', sans-serif;
}
.about-row {
  padding-top: 5vh;
  padding-bottom: 10vh;
  background-color: white;
  color: #222222;
  min-height: 70vh;
}
.about-icon {
  margin: 0px;
  line-height: 10vh;
  font-size: 7vh;
  letter-spacing: -3px;
  color: mediumseagreen;
}
.row {
  margin-bottom: 5vh;
}
@media (max-width: 359px) {
  .btn-responsive {
    padding: 2px 2px;
    font-size: 75%;
    line-height: 0.75;
    border-radius: 2px;
  }
}
@media (min-width: 360px) and (max-width: 767px) {
  .btn-responsive {
    padding: 4px 4px;
    font-size: 90%;
    line-height: 1;
    border-radius: 3px;
  }
}
@media (min-width: 768px) and (max-width: 992px) {
  .btn-responsive {
    padding: 4px 9px;
    font-size: 100%;
    line-height: 1.2;
  }
  .top-bar {
    margin-top: 12px;
  }
}
@media (min-width: 992px) {
  .btn-responsive {
    padding: 6px 12px;
    font-size: 120%;
    line-height: 1.5;
  }
  .top-bar {
    margin-top: 6px;
  }
}
#blogSection {
  padding: 5vw;
  padding-top: 15vh;
  padding-bottom: 15vh;
  width: 95vw;
}
.feature-label {
  line-height: 10vh;
}
.user-thumb {
  width: 18px;
  height: 18px;
  display: inline-block;
}
.myNav i,
.myNav span {
  color: white !important;
  display: inline-block !important;
}
.navbar-toggle {
  background-color: #DDD !important;
}
.icon-bar {
  background-color: mediumseagreen !important;
}
.collapsed > .icon-bar {
  background-color: #3F3F3F !important;
}
.fa-ul {
  margin-left: 45px !important;
}
.fa-ul > li {
  left: -48px;
}
.fa-ul > li a {
  padding-left: 2px !important;
}
ul .dropdown-menu {
  min-width: 128px !important;
  border-radius: 0px !important;
}
.dropdown .dropdown-menu {
  background-color: #E7E7E7 !important;
}
.open > .dropdown-menu {
  background-color: #E7E7E7 !important;
}
ul .dropdown-menu li {
  background-color: #E7E7E7 !important;
}
ul .dropdown-menu li a {
  padding: 3px 13px !important;
  font-size: 0.9em;
}
.dropdown-toggle {
  color: white !important;
}
.open > .dropdown-toggle {
  color: #222 !important;
}
.brand-fixer {
  float: none;
  padding-top: 8px;
}
/* --------------- radar -------------- */

.svgRadarCircle {
  stroke: #222;
  stroke-width: 2;
  fill: #ccffcc;
}
.svgArea {
  height: 80%;
  width: 100%;
}
#distDiv {
  width: 35vw;
  margin: auto;
  margin-bottom: 20px;
  text-align: center;
  padding: 0px;
  font-size: 1.4em;
  line-height: 1.5em;
}
#distInput {
  width: 100%;
  text-align: center;
  border: 0px none;
}
#slider {
  width: 40vw;
  margin: auto;
}
#slider .ui-slider-handle {
  outline: none !important;
}
#slider .ui-slider-handle:focus {
  outline: none !important;
}
.form-control {
  padding: 0px !important;
  box-shadow: none;
  height: 1.5em;
}
.brand {
  max-height: 40px;
  max-width: 100px;
  padding-top: 0;
  padding-bottom: 0;
}
.poiNode:hover {
  cursor: pointer;
}
.ui-widget-header,
.ui-button {
  border: 1px solid black !important;
  background-image: none !important;
  background-color: mediumseagreen !important;
}
.northBlipLabel {
  font-family: 'Ubuntu';
  font-size: 20px;
  font-weight: bold;
  fill: #222;
}
.centerBlip {
  font-family: 'FontAwesome';
  font-size: 20px;
  fill: mediumseagreen;
  stroke-width: 1.5;
  stroke: #222;
}
.ui-slider-handle {
  background: mediumseagreen !important;
}
.ui-slider-handle.ui-state-active {
  cursor: ew-resize;
}
.navbar .btn-group i span {
  border: 1px solid #444;
  font-family: 'Ubuntu';
  font-size: 10px;
}
.fa-search-2 {
  color: #666;
}
.fa-user-2 {
  color: #07f;
}
.fa-envelope {
  color: #fff;
}
.fa-star {
  color: #FF9900;
}
.notification-count {
  position: absolute;
  top: 7px;
  right: 0.6vh;
  border-radius: 8px;
  box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.7);
  background-color: #DC0D17;
  background-image: linear-gradient(#FA3C45, #DC0D17);
  padding: 3px 6px;
  text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.4);
  color: #FFF;
  font-family: 'Ubuntu';
  font-size: 0.24em;
}
.tool-btn {
  height: 100% !important;
  width: 100% !important;
}
.filters-menu {
  position: fixed;
  width: 50vw;
  max-width: 200px;
  top: 35vh;
  right: 0;
  background: #222;
  color: #FFF;
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
  box-shadow: 2px 2px 2px #222222;
  font-size: 1.3em;
}
.inner-wrapper {
  height: 30vh;
  max-height: 144px;
  padding: 20px 0px 20px 5px;
}
.filters-left {
  width: 20%;
  height: 100%;
  float: left;
  position: relative;
  padding: 0px 5px 0px 0px;
}
.filters-left span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
}
.filters-left span * {
  display: inline;
  padding: 0px 4px 0px 4px;
}
.filters-right {
  height: 100%;
  width: 80%;
  float: right;
  display: table;
}
.filters-right span {
  padding: 10px;
}
.inner-div {
  position: relative;
  height: 100%;
  vertical-align: middle;
  display: table-cell;
  width: 100%;
}
.radialGuide {
  fill: transparent;
  stroke: #666;
  stroke-width: 2px;
}
.user-blip {
  fill: mediumseagreen;
  stroke: #444;
  stroke-width: 1px;
  font-family: 'FontAwesome';
  font-size: 20px;
}
.business-blip {
  fill: dodgerblue;
  stroke: #444;
  stroke-width: 1px;
  font-family: 'FontAwesome';
  font-size: 20px;
}
.favorite-blip {
  fill: goldenrod;
  stroke: #444;
  stroke-width: 1px;
  font-family: 'FontAwesome';
  font-size: 20px;
}
.venue-blip {
  fill: #CC0000;
  stroke: #444;
  stroke-width: 1px;
  font-family: 'FontAwesome';
  font-size: 20px;
}
.hidden-blip {
  visibility: hidden;
}
.visible-blip {
  visibility: visible;
}
.inner-div span:hover,
.filters-left span:hover {
  cursor: pointer;
}
span i.fa-square-o {
  -moz-padding-right: 1px;
  -webkit-padding-right: 2px;
  padding-right: 2px;
}
.noselect {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
.ui-dialog.business-blip-dialog,
.ui-dialog.user-blip-dialog,
.ui-dialog.favorite-blip-dialog,
.ui-dialog.venue-blip-dialog {
  width: 95vw !important;
  max-width: 900px !important;
  height: 70vh !important;
  top: 10vh !important;
}
.ui-corner-all {
  border-radius: 0px !important;
  border-bottom-left-radius: 0px !important;
  border-bottom-right-radius: 0px !important;
  border-top-right-radius: 0px !important;
  border-top-right-radius: 0px !important;
}
.ui-dialog-titlebar.ui-widget-header {
  border: none !important;
}
.myDialogContainer {
  height: 100%;
  width: 100%;
  padding: 0px !important;
}
.star-rating {
  color: goldenrod;
}
.ui-dialog {
  padding: 0px;
}
.ui-dialog-titlebar button.ui-button {
  border: none !important;
}
.ui-dialog-titlebar .ui-state-default > .ui-icon,
.ui-dialog-titlebar .ui-state-default:hover > .ui-icon {
  background-image: url("https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/images/ui-icons_222222_256x240.png") !important;
}
.tab-content {
  border: 1px solid #DDD;
  border-top: none;
  bottom: 0px;
  margin-right: 1px;
  padding: 20px 10px;
  bottom: 0px;
}
.profile-details span {
  width: 80% !important;
  text-align: right;
  display: block;
}
.profile-details img {
  margin-left: auto;
  margin-right: auto;
  position: absolute;
  display: block;
}
.myDialogTop {
  margin-bottom: 20px;
  padding: 0px !important;
}

<!DOCTYPE html>
<html>

<head>
  <title>mygrant</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-capable" content="yes">

  <!-- 3rd Party STYLESHEETS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
  <link href='https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">

  <!-- /3rd Party STYLESHEETS -->

</head>

<body>
  <div class="right-menu-wrapper">
    <div id="loading" class="text-center">
      <i class="fa fa-spin fa-circle-o-notch"></i>
    </div>

    <nav class="navbar navbar-default">
      <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" 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 brand-fixer" href="#">
            LOGO
          </a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav myNav fa-ul">
            <li>
              <a href="#">
                <i class="fa fa-fw fa-compass fa-1x"></i><span>&nbsp; Discover</span>
              </a>
            </li>
            <li>
              <a href="#">
                <i class="fa fa-fw fa-cog fa-1x"></i><span>&nbsp; Settings</span>
              </a>
            </li>
          </ul>
          <ul class="nav navbar-nav navbar-right navbar-2nd">
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                Username <span class="caret"></span>
              </a>
              <ul class="dropdown-menu">
                <li>
                  <a href="#">
                    <i class="fa fa-fw fa-pencil-square-o fa-1x"></i><span>&nbsp; Account</span>
                  </a>
                </li>
                <li>
                  <a href="#">
                    <i class="fa fa-fw fa-eye fa-1x"></i><span>&nbsp; Visibility</span>
                  </a>
                </li>
                <li role="separator" class="divider"></li>
                <li>
                  <a href="#">
                    <i class="fa fa-fw fa-sign-out fa-1x"></i><span>&nbsp; Logout</span>
                  </a>
                </li>
              </ul>
            </li>
          </ul>
        </div>
        <!-- /.navbar-collapse -->
      </div>
      <!-- /.container-fluid -->
    </nav>

    <div class="container" id="containerMain">

    </div>


  </div>
  <!-- SCRIPTS -->

  <!-- 3rd party DON'T CHANGE LOAD ORDER!!!-->

  <!-- jQuery Minified with local failsafe -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script>
    window.jQuery || document.write('<script src="js/jquery-1.11.3.min.js"><\/script>')
  </script>

  <!-- Bootstrap Minified FAILSAFE MISSING -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

  <!-- jQuery UI Minified FAILSAFE MISSING -->
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>

  <!-- jQuery UI Touch Punch Local -->
  <script src="js/jquery.ui.touch-punch.min.js"></script>

</body>

</html>
&#13;
&#13;
&#13;

我在我的应用中使用dropdown选项从Bootstrap导航:当我点击下拉切换(在我的情况下为a元素)时,ul部分下拉列表中没有显示,但仅限于非折叠视图,即桌面。在移动设备中,折叠时它的行为应该如此。请注意,除了Bootstrap的自动行为外,HTML / CSS的其余部分没有任何变化。

点击后我检查它时,ul及其元素会相应地突出显示,而ul内联display: block应该是这样,所以元素都在那里。他们根本无法渲染,因为我无法弄清楚。

起初,我认为这可能是z-index问题,但ul高于其他所有问题。

不过,它之前没有任何问题,但我无法将其追溯到该状态。

任何人都知道为什么会这样或者我怎么找到原因?

1 个答案:

答案 0 :(得分:1)

你的问题是overflow: hidden两个div。

从CSS中删除它:

.navbar {
  overflow: hidden;
}
.navbar-2nd {
  overflow: hidden;
}

CODEPEN