How to slide nav bar from left instead from top?

前端 未结 9 1761
闹比i
闹比i 2020-12-02 18:49

Bootstrap supports toggling a navbar from the top. How can I slide it from the left when the screen-size is small?

For example:

In the screenshot pr

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 19:24

    Use this for right-to-left sliding:

    HTML :

    
    

    CSS:

    .nav{
        position: fixed;
        right:0;
        top: 70px;
        width: 250px;
        height: calc(100vh - 70px);
        background-color: #333;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
    
    }
    .nav-view{
        transform: translateX(0);
    }
    

    JS:

    $(document).ready(function(){
      $('a#click-a').click(function(){
        $('.nav').toggleClass('nav-view');
      });
    });
    

    Download source files: http://www.themeswild.com/read/slide-navigation-left-to-right

提交回复
热议问题