Search code examples
htmltwitter-bootstraptwitter-bootstrap-3responsive-designsemantic-markup

Bootstrap navbar-fixed-bottom on desktop and navbar-static-top on mobile?


Is there a way to keep the Bootstrap Navbar be navbar-fixed-bottom when it's on mobile, and navbar-static-top when on desktop? I was thinking of creating two navbars and hiding one and showing the other, though I'm not sure if that's fine; on a related note, is it alright to use two nav elements with the same role?


Solution

  • You can also do this by adding and removing the class of the navbar using javascript jquery according screen width.

    if ($(window).width() > 330) {
     $('.navbar').addClass('navbar-static-top');
    }
    else
    {
     $('.navbar').addClass('navbar-fixed-bottom');
    }
    

    It will work for sure