Bulma: any way to make navbar-dropdown work in mobile like in desktop ?

Created on 29 Oct 2017  路  3Comments  路  Source: jgthms/bulma

I need to keep the navbar-dropdown in mobile.

Any option for this?

Most helpful comment

Adding both css and javascript. navbar-dropdown works on mobile

.navbar-item {

    &.has-dropdown {
      .navbar-dropdown {
        display: none;
      }
      &.is-active {
        .navbar-dropdown {
          display: block;
        }
       }
     }
  }
$(".navbar-item.has-dropdown").click(function(e) {
      if ($(".navbar-burger").is(':visible')) {
        $(this).toggleClass("is-active");
      }
  });
  $(".navbar-item > .navbar-link").click(function(e) {
      if ($(".navbar-burger").is(':visible')) {
        e.preventDefault();
      }
  });
  $(window).resize(function(e) {
    if (!$(".navbar-burger").is(':visible') && $(".navbar-item.has-dropdown.is-active").length) {
      $(".navbar-item.has-dropdown.is-active").removeClass('is-active');
    }
  });

All 3 comments

It鈥檚 not possible because it uses the hover state. But try using a regular drodpwon instead, within a navbar item!

No javascript workaround, just place this in your mobile media query (It's SASS but you can turn it to css easily)
`
.navbar-item {

    &.has-dropdown {
      .navbar-dropdown {
        display: none;
      }
      &.is-active {
        .navbar-dropdown {
          display: block;
        }
       }
     }
  }

`

Adding both css and javascript. navbar-dropdown works on mobile

.navbar-item {

    &.has-dropdown {
      .navbar-dropdown {
        display: none;
      }
      &.is-active {
        .navbar-dropdown {
          display: block;
        }
       }
     }
  }
$(".navbar-item.has-dropdown").click(function(e) {
      if ($(".navbar-burger").is(':visible')) {
        $(this).toggleClass("is-active");
      }
  });
  $(".navbar-item > .navbar-link").click(function(e) {
      if ($(".navbar-burger").is(':visible')) {
        e.preventDefault();
      }
  });
  $(window).resize(function(e) {
    if (!$(".navbar-burger").is(':visible') && $(".navbar-item.has-dropdown.is-active").length) {
      $(".navbar-item.has-dropdown.is-active").removeClass('is-active');
    }
  });
Was this page helpful?
0 / 5 - 0 ratings

Related issues

scottgrayson picture scottgrayson  路  3Comments

rogervila picture rogervila  路  3Comments

Yard8 picture Yard8  路  3Comments

swamikevala picture swamikevala  路  3Comments

leofontes picture leofontes  路  3Comments