【发布时间】:2022-07-15 16:47:31
【问题描述】:
我得到了一个类似这样的结构:
<div>
<div>
<div>
...
我正在尝试将内部 div 的高度从 0 转换为 100%。过渡有效,但父母的高度不会平滑变化,而是在过渡之前/之后突然跳跃(参见 gif)。
所有三个 div 都有弹性显示。内部div的过渡是:
.expandable {
transition: max-height 2s linear;
max-height: 0;
height: auto;
}
.expandable.expanded {
max-height: 100%;
}
【问题讨论】: