所以一个快速的谷歌搜索揭示了这一点:
.our_content {
/* Initially we don't want any height, and we want the contents to be hidden */
max-height: 0;
overflow: hidden;
/* Set our transitions up. */
-webkit-transition: max-height 0.8s;
-moz-transition: max-height 0.8s;
transition: max-height 0.8s;
}
.outside_box:hover .our_content {
/* On hover, set the max-height to something large. In this case there's an obvious limit. */
max-height: 200px;
}
当您单击 js 时,您需要更改类并应用。我很好奇你的动画需要多么优美。如果它们需要抛光,我建议使用淡入淡出和调整大小。
tr {
max-height: 0;
overflow: hidden;
-webkit-transition: max-height 360ms;
}
tr.selected {
-webkit-animation:
grow 420ms ease-in-out,
fadeIn 540ms ease-in;
}
tr.deslection {
-webkit-animation:
shrink 420ms ease-in-out,
fadeOut fadeIn 540ms ease-out;
}
@-webkit-keyframes grow {
0% {
max-height: /*initial row height*/;
}
100% {
max-height: /*new row height*/;
}
}
@-webkit-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@-webkit-keyframes shrink {
0% {
max-height: /*new row height*/;
}
100% {
max-height: /*initial row height*/;
}
}
@-webkit-keyframes fadeOut {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
听起来你理解用 js 添加和删除类,所以我不解释了。如果您需要其他帮助,请发布一些代码。祝你好运!