【发布时间】:2014-04-20 22:12:54
【问题描述】:
我正在尝试在元素接收到某个类时创建 CSS 过渡。到目前为止,切换更改有效(这意味着 ng-class 工作正常),但动画没有发生。
这是我的代码:
.intro-text{
height:auto;
-webkit-transition: height 200ms ease-out;
-moz-transition: height 200ms ease-out;
-o-transition: height 200ms ease-out;
transition: height 200ms ease-out;
}
.intro-text.hide{
height:0;
}
还有 HTML:
<div class="intro-text" ng-class="{'hide':clicked}">
<h1>Howdy stranger!</h1>
<h3>Use the form below to search for an artist and start building your record collection!</h3>
</div>
我错过了什么?
编辑:我已将问题缩小到引导程序。如果我包含 bootstrap.min.css,动画将不起作用,没有它,它会完美运行。知道为什么吗?
编辑 2:已修复!问题是 .hide 和 .hidden 都是 Bootstrap 中定义的类,所以它覆盖了我的样式,解析了 display:none;在动画可见之前。当将课程更改为另一个名称时,它得到了修复:)
【问题讨论】:
-
似乎只有在
height有一些数值而不是auto时才有效:plnkr.co/edit/ff1O5uSKGtHjdmntVpr1?p=preview -
在我的例子中,不起作用:SS plnkr.co/edit/JLTJ1BhMTHHmxckGEg5U?p=preview
标签: html css angularjs css-transitions