【发布时间】:2016-07-28 05:56:54
【问题描述】:
我正在尝试使用 ng-animate 和 CSS 样式实现幻灯片效果,但无法弄清楚我的代码有什么问题...
我可以使用min-height 和max-height 的百分比值来执行此操作吗?我不能在 px 中使用固定值。
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app>
<a href="#" class="toggle-menu" ng-click="collapsed=!collapsed">Click to toggle menu</a>
<div class="menu" ng-show="collapsed" ng-animate="{show: 'menu-show', hide: 'menu-hide'}">
<div class="files">
<input type="checkbox" />
<label>first</label>
<input type="checkbox" />
<label>second</label>
</div>
<div class="diffs">
<input type="checkbox" />
<label>first</label>
<input type="checkbox" />
<label>second</label>
</div>
</div>
</div>
CSS:
.menu-show-setup, .menu-hide-setup {
transition:all 0.5s ease-out;
overflow:hidden
}
.menu-show-setup {
max-height:0;
}
.menu-show-setup.menu-show-start {
max-height:25%;
}
.menu-hide-setup {
max-height:25%;
}
.menu-hide-setup.menu-hide-start {
max-height:0;
}
【问题讨论】:
-
在描述您遇到的实际错误时能否更具描述性?您能否发布使用调试器时看到的任何错误?
-
我的问题是幻灯片效果不起作用。调试器中没有错误。
-
查看我发布的关于 ng-animate 的这个问题,它可能对您有所帮助:stackoverflow.com/a/33927043/4515720
-
您的小提琴没有将 ng-animate 定义为依赖项,因此不使用它。见:docs.angularjs.org/api/ngAnimate
-
@S.B.是的,我认为 O.P. 使用显示应用程序依赖关系的 app.js 文件更新帖子会很有帮助。