how to disable scroll in md-menu?

2019-09-16 09:18发布

I use angular-material. I want to hide scroll in menu. And to have just menu with fixed height. but it doesn't make height big enough to disable scroll. here is my code:

<md-toolbar  ng-init="vm.hasLogged()" class="sidebar-left-toolbar" md-theme="{{::triSkin.elements.logo}}">

<md-menu md-offset="-200 56">
        <h2 flex class="sidebar-left-title"  ng-click="$mdOpenMenu()">{{::vm.sidebarInfo.appName}}</h2>

    <md-menu-content  aria-label="open menu" width="4" style="height1: 250px">
        <md-menu-item >
            <md-button md-prevent-menu-close="md-prevent-menu-close">
                Setup
            </md-button>
        </md-menu-item>
        <md-menu-item>
            <md-button md-prevent-menu-close="md-prevent-menu-close">
                Work
            </md-button>
        </md-menu-item>
        <md-menu-divider></md-menu-divider>
        <md-menu-item>
            <md-button md-prevent-menu-close="md-prevent-menu-close">
                Reports
            </md-button>
        </md-menu-item>
        <md-menu-item>
            <md-button md-prevent-menu-close="md-prevent-menu-close">
                Workflow
            </md-button>
        </md-menu-item>
        <md-menu-item>
            <md-button md-prevent-menu-close="md-prevent-menu-close">
                Cuan
            </md-button>
        </md-menu-item>
        <md-menu-item>
            <md-button md-prevent-menu-close="md-prevent-menu-close">
                Admin
            </md-button>
        </md-menu-item>
        <md-menu-item>
            <md-button  ng-if="vm.isLogged" ng-click="vm.logout()">
                Logout
            </md-button>
        </md-menu-item>
    </md-menu-content>
</md-menu>

I have tried with style="height: xxx" it makes menu smaller. but not bigger

2条回答
Evening l夕情丶
2楼-- · 2019-09-16 09:53

You can use CSS - CodePen

CSS

md-menu-content {
  overflow-y: hidden;
  min-height: 400px;
}

The only problem with this solution is that it will affect all menus. There doesn't seem to be a way to assign a class to the menu like other AM directives.

查看更多
男人必须洒脱
3楼-- · 2019-09-16 10:07

That's an old question, but I came with the same problem.

I solve it this way:

<md-menu-content width="4" class="maxHeightNone">

.maxHeightNone{
   max-height: none;
}

This way, you don't need to specify the min-height and it will adapt to the content of the md-menu.

查看更多
登录 后发表回答