Foundation 6导航切换菜单显示在按钮顶部

时间:2018-08-27 06:47:16

标签: html css css3 zurb-foundation responsive

我在一个网站上工作,在使用基础6(大)时,我需要移动导航的默认断点为63.9375断点。我已将“数据隐藏”更改为大,并将ul类更改为“大水平”。我还调整了CSS,以使最大宽度为63.9375。

但是。在40em和64em之间,切换菜单时,菜单会显示在徽标和按钮的顶部,而不是下拉至下方。我知道这与CSS有关,但我无法弄清楚。

HTML:

<div data-sticky-container>
  <div data-sticky data-margin-top='0' data-top-anchor="header:bottom" data-btm-anchor="content:bottom">
          <nav class="top-bar topbar-responsive">
      <div class="top-bar-title"> <span data-responsive-toggle="topbar-responsive" data-hide-for="large">
        <button class="menu-icon" type="button" data-toggle></button>
        </span> <a class="topbar-responsive-logo" href="#"><strong>Logo Here</strong></a> </div>
      <div id="topbar-responsive" class="topbar-responsive-links">
        <div class="top-bar-right">
          <ul class="menu simple vertical large-horizontal">
            <li><a href="#">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Patient Info</a></li>
            <li><a href="#">Procedures</a></li>
            <li><a href="#">Physicians</a></li>
            <li><a href="#">Contact</a></li>
            <li>
              <button type="button" class="button hollow topbar-responsive-button">Patient Portal</button>
            </li>
          </ul>
        </div>
      </div>
    </nav>
  </div>
</div> 

CSS:

/*----------------------- NAVIGATION* -----------------------*/
.header {
  padding: 1rem 0;
}

[data-sticky] {
  width: 100%;
}

.top-bar {
  padding: 2rem;
  transition: padding .25s ease;
}

.is-stuck .top-bar {
  padding: 1rem;
  transition: padding .25s ease;
}

.is-stuck .topbar-responsive {
  padding: 1rem;
  transition: padding .25s ease;
}

.topbar-responsive {
  background: #2c3840;
  padding: 1rem 1.5rem;
  z-index: 15;
  transition: padding .25s ease;
}

.topbar-responsive .topbar-responsive-logo {
  color: #fefefe;
  vertical-align: middle;
}

.topbar-responsive .menu {
  background: #2c3840;
}

.topbar-responsive .menu li:last-of-type {
  margin-right: 0;
}

.topbar-responsive .menu a {
  color: #fefefe;
  transition: color 0.15s ease-in;
}

.topbar-responsive .menu a:hover {
  color: #c6d1d8;
}

@media screen and (max-width: 63.9375em) {
  .topbar-responsive .menu a {
    padding: 0.875rem 0;
  }
}
.topbar-responsive .menu .topbar-responsive-button {
  color: #fefefe;
  border-color: #fefefe;
  border-radius: 5000px;
  transition: color 0.15s ease-in, border-color 0.15s ease-in;
}

.topbar-responsive .menu .topbar-responsive-button:hover {
  color: #c6d1d8;
  border-color: #c6d1d8;
}
@media screen and (max-width: 63.9375em) {
  .topbar-responsive .menu .topbar-responsive-button {
    width: 100%;
    margin: 0.875rem 0;
  }
}

@media screen and (max-width: 39.9375em) {
  .topbar-responsive {
    padding: 0.75rem;
  }

  .topbar-responsive .top-bar-title {
    position: relative;
    width: 100%;
  }

  .topbar-responsive .top-bar-title span {
    position: absolute;
    right: 0;
    border: 1px solid #fefefe;
    border-radius: 5px;
    padding: 0.25rem 0.45rem;
    top: 50%;
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    transform: translateY(-50%);
  }

  .topbar-responsive .top-bar-title span .menu-icon {
    margin-bottom: 4px;
  }
}
@media screen and (min-width: 40em) and (max-width: 63.9375em) {
  .topbar-responsive .top-bar-title span {
    position: absolute;
    right: 5px;
    border: 1px solid #fefefe;
    border-radius: 5px;
    padding: 0.25rem 0.45rem;
    top: 50%;
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    transform: translateY(-50%);
  }

  .topbar-responsive .top-bar-title span .menu-icon {
    margin-bottom: 4px;
  }
}
@-webkit-keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@-webkit-keyframes slideDown {
  0% {
    -webkit-transform: translateY(-100%);
    transform: translateY(-100%);
  }
  100% {
    -webkit-transform: translateY(0%);
    transform: translateY(0%);
  }
}
@keyframes slideDown {
  0% {
    -webkit-transform: translateY(-100%);
    transform: translateY(-100%);
  }
  100% {
    -webkit-transform: translateY(0%);
    transform: translateY(0%);
  }
}
@media screen and (max-width: 63.9375em) {
  .topbar-responsive-links {
    -webkit-animation-fill-mode: both;
    animation-fill-mode: both;
    -webkit-animation-duration: 0.5s;
    animation-duration: 0.5s;
    width: 100%;
    -webkit-animation: fadeIn 1s ease-in;
    animation: fadeIn 1s ease-in;
  }
}

测试平台的网址:https://codepen.io/elisethechemist/pen/EeKyvb

非常感谢您的帮助!

0 个答案:

没有答案