悬停的动画元素高度
我正在尝试为悬停上的某些元素的高度启动。我使用 max-height 来操纵动画:您在这里看到:
.container {
height: auto;
}
.hiddenContent {
max-height: 0px;
overflow: hidden;
transition: max-height 1s ease;
}
.container:hover>.hiddenContent {
max-height: 250px;
transition: max-height 1s ease;
}
<div class="container">
<h2>Hover me to expand</h2>
<div class="hiddenContent">
<h4>Hidden title</h4>
<p>Hidden content lorem ipsum sid dolor amet</p>
</div>
</div>
<div class="container">
<h2>Hover me to expand</h2>
<div class="hiddenContent">
<h4>Hidden title</h4>
<p>Hidden content lorem ipsum sid dolor amet</p>
</div>
</div>
<div class="container">
<h2>Hover me to expand</h2>
<div class="hiddenContent">
<h4>Hidden title</h4>
<p>Hidden content lorem ipsum sid dolor amet</p>
</div>
</div>
当我从一个元素导航到另一个元素时出现问题:2动画(开头一个和结尾)不是同时进行的。闭合一开始时,开头完成。我该如何解决?
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那是因为您正在动画Max-Height。
这是我发现的一个很好的解释:
CSS同时过渡
that's because you're animating max-height.
Here's a good explanation I found:
CSS transition simultaneous
just try to animate height