我有一个 CSS 表。所有行的高度相同,但当用户单击其中一行时,所选行应占据整个表格高度,其余行应逐渐消失。我通过简单的设置就可以工作display:none
在所有其他行上,但我想做一些过渡。
我尝试过设置max-height
到 100%,然后将其更改为 0,但这只会使所选行比其余行稍大,而其余行保持原样。我尝试过改变height
从 100% 到 0,但高度为 100% 时,顶行很大,其余行大约 15px 高。
本质上,我想在之间过渡height:auto
to height:0
,但这不起作用。它所做的只是来回快速移动,没有过渡。关于如何使其在表行上工作有什么想法吗?
谷歌快速搜索发现this http://css3.bradshawenterprises.com/animating_height/:
.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添加和删除类,所以我不解释这一点。如果您需要其他帮助,请发布一些代码。祝你好运!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)