小于默认导航栏高度导致问题

时间:2017-01-30 17:54:12

标签: html css twitter-bootstrap animation

我喜欢低于正常navbar高度的外观,因为它似乎是一种流行的设计趋势。

但是,这似乎在打开collapse菜单时会出现问题。

在这里,您可以看到展开collapse navbar-collapse菜单的各个阶段。首先是我的正常navbar,最小高度为30px。然后,当我单击切换按钮时,导航栏会短暂扩展为50px,最后显示全屏菜单。

navbar height issue

仅此一点并不是什么大问题(虽然我更喜欢平滑过渡)但是菜单的展开和折叠动画似乎没有按照预期的那样降低navbar高度。

为什么会发生这种情况?或者,我的造型中是否有其他与navbar高度无关但又导致问题的东西?

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Quicksand', sans-serif;
}

body {
    margin-top: 60px;
}

#main-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.container {
  margin: 0 auto;
}

.article {
    flex: 1;
}

/*START Shrinks the default navbar height*/
.navbar {
  min-height: 30px;
  //max-height: 40px;
  margin: 0px;
  width: 100%;
  background-color: #444;
}

.navbar-nav > li,
.navbar-nav > li > a,
.navbar-nav > li > a:link,
.navbar-nav > li > a:visited {
  padding: 4px 5px 0px 5px;
  //height: 30px;
  color: white;
  font-size: 1.1em;
  font-weight: 300;
  margin: 2px 8px 0 0;
}
/*END*/

.nav.navbar-nav li a:focus,
.nav.navbar-nav li a:active,
.nav.navbar-nav li a:hover {
  color: white;
  opacity: 0.8;
}

.navbar-toggle {
  float: left;
  border: none;
  margin-top: 10px;
  margin-left: 10px;
  padding: 4px;
}

.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:active,
.navbar-default .navbar-toggle:focus {
  background-color: #444;
}

/*Displays navbar dropdown on hover */
ul.nav li.dropdown:hover ul.dropdown-menu {
  display: block;
}

.navbar-default .navbar-header .icon-bar {
  background-color: white;
  width: 22px;
}

.navbar-default .navbar-toggle:hover .icon-bar {
  background-color: #EFEFEF;
}

.navbar .navbar-brand {
    color: white;
    margin: -4px 20px -3px 0;
    font-size: 1.7em;
    font-family: 'Orbitron', 'Dosis', sans-serif;
}

.navbar .navbar-brand:focus,
.navbar .navbar-brand:hover {
  color: white;
  opacity: 0.8;
}


/*Change hamburger menu to "x" on click */
.navbar-toggle .icon-bar {
  width: 22px;
  transition: all 0.4s;
}
.navbar-toggle .top-bar {
  transform: rotate(45deg);
  transform-origin: 10% 10%;
}
.navbar-toggle .middle-bar {
  opacity: 0;
}
.navbar-toggle .bottom-bar {
  transform: rotate(-45deg);
  transform-origin: 10% 90%;
}
.navbar-toggle.collapsed .top-bar {
  transform: rotate(0);
}
.navbar-toggle.collapsed .middle-bar {
  opacity: 1;
}
.navbar-toggle.collapsed .bottom-bar {
  transform: rotate(0);
}

.navbar.navbar-default .navbar-collapse { 
  border: none;
  box-shadow: none; 
}

/*Change Background color of toggle dropdown*/
.collapse.navbar-collapse {
    background-color: #444;
    min-width: 100%;
    min-height: 100%;
}

h3 + p {
  line-height: 1.8em;
}


footer {
    background-color: #444;
    color: white;
    height: 250px;
    padding: 8px;
    min-width: 100%;
    margin: 0 auto;
}

footer a,
footer a:link,
footer a:visited {
  color: white;
  text-decoration: none;
}

footer a:hover,
footer a:active,
footer a:focus {
  opacity: 0.8;
}

.tagline {
  text-align: center;
}

.footer-sub {
  border: thin white solid;
  margin: 0 2px 7px 0;
  float: left;
  width: 200px;
  padding: 5px;
}

.fa-plus {
  margin-top: 3px;
  float: right;
}

.fa-plus:hover {
  opacity: 0.8;
  cursor: pointer;
}

#location-detail {
  display: none;
}

a#location:focus + #location-detail {
  display: block;
}


@media (max-width: 992px) {
  .navbar-nav > li,
  .navbar-nav > li > a,
  .navbar-nav > li > a:link,
  .navbar-nav > li > a:visited,
  .navbar-nav > li > a:hover {
    font-size: 1.05em;
  }
}

@media (max-width: 767px) {
  .navbar .navbar-brand {
    position: absolute;
    left: 50%;
    margin-left: -110px !important;
    display: block;
  }

  .navbar-collapse {
    text-align: center;
  }

  .navbar-collapse li {
    display: none;
  }

  .collapse.navbar-collapse {
    background-color: #444;
    position: fixed;
    min-width: 100%;
    min-height: 100%;
    font-size: 1.3em;
    text-align: center;
    padding-top: 20px;

    transition-property: all;
    transition-duration: 0.2s;
    transition-timing-function: linear;
  }

  .collapse.navbar-collapse li {
    display: block;
    margin-bottom: 15px;
  }

}


<div class="navbar navbar-default navbar-fixed-top">

              <div class="container">

                   <div class="navbar-header">

                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">

                             <span class="sr-only">Toggle navigation</span>

                             <span class="icon-bar top-bar"></span>
                             <span class="icon-bar middle-bar"></span>                               
                             <span class="icon-bar bottom-bar"></span>

                        </button>

                        <!--<a href="" class="navbar-brand"><img class="logo" src="../images/eclipse-new.png"/></a> -->
                        <a href="#" class="navbar-brand">Eclipse Music</a>

                   </div> <!-- end of navbar-header -->

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

                         <ul class="nav navbar-nav">

                         <!--<li><a href=""><span class="glyphicon glyphicon-home"></span>Home</a></li>-->
                          <li><a href="">Effects</a></li>
                          <li><a href="http://www.eclipsemusic.org/guitars-basses-and-amps">Guitar</a></li>
                          <li><a href="">Bass</a></li>
                          <li><a href="">Amps</a></li>

                          <li><a href="">Lessons</a></li>
                          <li class="dropdown">

                               <a href="about/about.php">About<!--&nbsp;<i class="fa fa-caret-down"></i>--></a>

                               <ul class="dropdown-menu">
                                     <li><a href="#">Directions</a></li>
                                     <li><a href="#">Contact Us</a></li>
                                     <li><a href="#">Blog</a></li>
                               </ul>

                          </li>

                         </ul>

                   </div> <!-- end of collapse navbar-collapse -->

              </div> <!-- end of container -->

         </div> <!-- end of navbar navbar-default navbar-fixed-top -->

Here is my site in progress。我尝试将样式和标记复制到JS Fiddle,但它与我的网页显示的不匹配。

0 个答案:

没有答案