onTheInternet
onTheInternet

Reputation: 7253

Foundation Top-Bar not working at certain sizes

I'm using Zurbs responsive framework foundation.

I decided I wanted the top bar to turn into a hamburger icon at a larger screen, because I have a lot of menu options and they push down to two lines when viewing the site on a medium sized screen such as a tablet.

So I found the media query where the size is being determined

@media only screen and (min-width: 40rem) {...}

I changed this to be 1025 pixels, and now it displays on screens that are 1025px and smaller. The issue is that the actual menu will not open or stay open when opened on smaller screens and made larger.

I think this has to do with a max-width set somewhere but the max-widths that I found in that media query aren't changing anything.

Here's the entire query

@media only screen and (min-width: 1024px) {
  .top-bar {
    background: #333333;
    overflow: visible; }
    .top-bar:before, .top-bar:after {
      content: " ";
      display: table; }
    .top-bar:after {
      clear: both; }
    .top-bar .toggle-topbar {
      display: none; }
    .top-bar .title-area {
      float: left; }
    .top-bar .name h1 a {
      width: auto; }
    .top-bar input,
    .top-bar .button,
    .top-bar button {
      font-size: 0.875rem;
      position: relative;
      height: 1.75rem;
      top: 0.53125rem; }
    .top-bar.expanded {
      background: #333333; }

  .contain-to-grid .top-bar {
    /*max-width: 62.5rem;*/
    margin: 0 auto;
    margin-bottom: 0; }

  .top-bar-section {
    transition: none 0 0;
    left: 0 !important; }
    .top-bar-section ul {
      width: auto;
      height: auto !important;
      display: inline; }
      .top-bar-section ul li {
        float: left; }
        .top-bar-section ul li .js-generated {
          display: none; }
    .top-bar-section li.hover > a:not(.button) {
      background-color: #555555;
      background: #333333;
      color: #FFFFFF; }
    .top-bar-section li:not(.has-form) a:not(.button) {
      padding: 0 0.9375rem;
      line-height: 2.8125rem;
      background: #f68c3b; }
      .top-bar-section li:not(.has-form) a:not(.button):hover {
        background-color: #555555;
        background: pink; }
    .top-bar-section li.active:not(.has-form) a:not(.button) {
      padding: 0 0.9375rem;
      line-height: 2.8125rem;
      color: #FFFFFF;
      background: #008CBA; }
      .top-bar-section li.active:not(.has-form) a:not(.button):hover {
        background: #0078a0;
        color: #FFFFFF; }
    .top-bar-section .has-dropdown > a {
      padding-right: 2.1875rem !important; }
      .top-bar-section .has-dropdown > a:after {
        content: "";
        display: block;
        width: 0;
        height: 0;
        border: inset 5px;
        border-color: rgba(255, 255, 255, 0.4) transparent transparent transparent;
        border-top-style: solid;
        margin-top: -2.5px;
        top: 1.40625rem; }
    .top-bar-section .has-dropdown.moved {
      position: relative; }
      .top-bar-section .has-dropdown.moved > .dropdown {
        display: block;
        position: absolute !important;
        height: 1px;
        width: 1px;
        overflow: hidden;
        clip: rect(1px, 1px, 1px, 1px); }
    .top-bar-section .has-dropdown.hover > .dropdown, .top-bar-section .has-dropdown.not-click:hover > .dropdown {
      display: block;
      position: static !important;
      height: auto;
      width: auto;
      overflow: visible;
      clip: auto;
      position: absolute !important; }
    .top-bar-section .has-dropdown > a:focus + .dropdown {
      display: block;
      position: static !important;
      height: auto;
      width: auto;
      overflow: visible;
      clip: auto;
      position: absolute !important; }
    .top-bar-section .has-dropdown .dropdown li.has-dropdown > a:after {
      border: none;
      content: "\00bb";
      top: 1rem;
      margin-top: -1px;
      right: 5px;
      line-height: 1.2; }
    .top-bar-section .dropdown {
      left: 0;
      top: auto;
      background: transparent;
      min-width: 100%; }
      .top-bar-section .dropdown li a {
        color: #FFFFFF;
        line-height: 2.8125rem;
        white-space: nowrap;
        padding: 12px 0.9375rem;
        background: #333333; }
      .top-bar-section .dropdown li:not(.has-form):not(.active) > a:not(.button) {
        color: #FFFFFF;
        background: #333333; }
      .top-bar-section .dropdown li:not(.has-form):not(.active):hover > a:not(.button) {
        color: #FFFFFF;
        background-color: #555555;
        background: #333333; }
      .top-bar-section .dropdown li label {
        white-space: nowrap;
        background: #333333; }
      .top-bar-section .dropdown li .dropdown {
        left: 100%;
        top: 0; }
    .top-bar-section > ul > .divider, .top-bar-section > ul > [role="separator"] {
      border-bottom: none;
      border-top: none;
      border-right: solid 1px #4e4e4e;
      clear: none;
      height: 2.8125rem;
      width: 0; }
    .top-bar-section .has-form {
      background: #333333;
      padding: 0 0.9375rem;
      height: 2.8125rem; }
    .top-bar-section .right li .dropdown {
      left: auto;
      right: 0; }
      .top-bar-section .right li .dropdown li .dropdown {
        right: 100%; }
    .top-bar-section .left li .dropdown {
      right: auto;
      left: 0; }
      .top-bar-section .left li .dropdown li .dropdown {
        left: 100%; }

  .no-js .top-bar-section ul li:hover > a {
    background-color: #555555;
    background: #333333;
    color: #FFFFFF; }
  .no-js .top-bar-section ul li:active > a {
    background: #008CBA;
    color: #FFFFFF; }
  .no-js .top-bar-section .has-dropdown:hover > .dropdown {
    display: block;
    position: static !important;
    height: auto;
    width: auto;
    overflow: visible;
    clip: auto;
    position: absolute !important; }
  .no-js .top-bar-section .has-dropdown > a:focus + .dropdown {
    display: block;
    position: static !important;
    height: auto;
    width: auto;
    overflow: visible;
    clip: auto;
    position: absolute !important; } }

Upvotes: 0

Views: 521

Answers (2)

rafibomb
rafibomb

Reputation: 535

If you are using the CSS download only, you can change the top-bar breakpoint with CSS changes in 2 places. Here is a link to an answer posted

http://foundation.zurb.com/forum/posts/1053-changing-topbar-breakpoint-using-css

Upvotes: 0

3mpetri
3mpetri

Reputation: 599

You don't have to "hack" the Tob Bar css to display mobile layout on certain breakpoints. All you have to do is edit the existing Foundation settings css file.

So, for example, Top Bar has a set of available SCSS variables, and you can check them here - http://foundation.zurb.com/docs/components/topbar.html

The thing you are looking for is:

$topbar-breakpoint: #{lower-bound($medium-range)}; // Change to 9999px for always mobile layout

Upvotes: 0

Related Questions