[英]Toggle-only sidenav with Angular-Material?
I want a side menu that is closed by default on any screen size, and will always open on top of other content. 我想要一个在任何屏幕尺寸上默认关闭的侧边菜单,并且将始终打开其他内容。 No matter what I try though, it always switches at widths over 960px.
无论我尝试什么,它总是切换宽度超过960px。
This is what my menu looks like now: 这就是我的菜单现在的样子:
<md-sidenav is-locked-open="false" class="md-sidenav-right md-whiteframe-z2" component-id="right">
<md-toolbar class="md-theme-dark">
<div class="md-toolbar-tools">
<md-button ng-click="toggleMenu()" class="md-button-colored"><core-icon icon="polymer"></core-icon></md-button>
<span flex></span>
</div>
</md-toolbar>
<md-content class="md-content-padding">
<md-button ng-click="toggleMenu()" class="md-button-colored">Stuff</md-button>
</md-content>
</md-sidenav>
And my controller: 而我的控制器:
.controller('HomeCtrl', function ($scope, $mdSidenav) {
$scope.toggleMenu = function() { $mdSidenav('right').toggle(); };
})
I got is-locked-open from the website but I can't find that anywhere in their javascript. 我从网站上被锁定打开但我无法在他们的javascript中找到它。
You can use the is-locked-open attribute in md-sidenav to control the locking open of the sidenav. 您可以使用md-sidenav中的is-locked-open属性来控制sidenav的锁定打开。 This will lock the sidenav when browser width is 1000px.
当浏览器宽度为1000px时,这将锁定sidenav。
<md-sidenav is-locked-open="$media('min-width: 1000px')"></md-sidenav>
To have is forever unlocked, this worked for me: 为了永远解锁,这对我有用:
<md-sidenav is-locked-open="$media('')"></md-sidenav>
sidenav通过在angular-material.css中注释掉以下样式而一直隐藏
@media (min-width: 960px) { md-sidenav { /* position: static; -webkit-transform: translate3d(0, 0, 0) !important; transform: translate3d(0, 0, 0) !important; } .md-sidenav-backdrop { display: none !important;*/ } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.