Angular 2 Material 2 Sidenav Toolbar collapse like Navigation Drawer

前端 未结 2 1445
自闭症患者
自闭症患者 2021-02-09 04:59

I have a sidenav and a nested toolbar
toolbar.html


    

        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-09 05:34

    This can be achieved using a simple css hack. We can call methods increase() and decrease() that changes the width of sidenav based on some event like mouseenter and mouseleave or in your case onClick of "toolbar-menu-button"

    
    

    This will incerese the width of sidenav when we point on sidenav and decrease the width when we point the mouse pointer at some other place.

      increase(){
        this.sidenavWidth = 15;
      }
      decrease(){
        this.sidenavWidth = 4;
      }
    

    Have a look at this demo :- https://mini-sidenav.firebaseapp.com/

    and the github repo :- https://github.com/Ravi-Rajpurohit/mini-md-sidenav

    I hope this helps :-)

提交回复
热议问题