Bootstrap 4 mobile nav bar slide from left

ramzan00 picture ramzan00 · May 12, 2017 · Viewed 41.2k times · Source

I am using the latest version of bootstrap. Kind of tried various things on my own and after that I thought I might find something on stackoverflow. But kind didn't get the thing. I mean how it works?

This is my code. I am not gonna add any custom style here since they didn't really work that well instead they created some error.

I also checked this post also Bootstrap - How to slide nav bar from left instead from top I tried all the answer from there but it didn't work for me.

Answer

Zim picture Zim · May 12, 2017

You can override the transition styles for the navbar-collapse like this...

Demo

@media (max-width: 992px) {
    .navbar-collapse {
        position: fixed;
        top: 50px; /* adjust to height of navbar */
        left: 0;
        padding-left: 15px;
        padding-right: 15px;
        padding-bottom: 15px;
        width: 75%;
        height: 100%;
    }

    .navbar-collapse.collapsing {
        left: -75%;
        transition: height 0s ease;
    }

    .navbar-collapse.show {
        left: 0;
        transition: left 300ms ease-in-out;
    }

    .navbar-toggler.collapsed ~ .navbar-collapse {
        transition: left 500ms ease-in-out;
    }
}

Demo - slide from right
Demo - slide from left
Demo - slide from left (full height)