【发布时间】:2020-08-14 02:42:05
【问题描述】:
我的 HTML:
<div class="home-intro" id="home-intro">
<h2>
<a>Some really long text</a>
</h2>
</div>
<div id="arrow"><i class="fa fa-angle-double-down fa-2x"></i></div>
我的 CSS:
.home-intro {
background: #34373b;
color: #fff;
padding: 15px 0 0;
max-height: 67px;
overflow: hidden;
}
我有一个 javascript,当您单击 div <div id="arrow"> 时,它会将 max_marquee 类添加到 home-intro,所以类似于 <div class="home-intro max_marquee" id="home-intro">
max_marquee 的 CSS 是:
.max_marquee {
max-height: none;
transition: max-height ease-in-out 0.5s;
}
我想知道当高度扩大时如何使过渡工作,我知道我需要为过渡工作设置一个高度,但我想知道是否有解决方法,因为我真的不知道高度为什么我需要它是最大高度:无。
【问题讨论】:
-
您的问题没有简单的解决方案,因为您无法转换
auto值,但有很多解决方法。这篇文章深入解释了这个问题:css-tricks.com/using-css-transitions-auto-dimensions
标签: html css css-transitions