CSS过渡表 - 行高

时间:2014-03-15 21:30:57

标签: css css3 css-transitions css-tables row-height

我有一张CSS表。所有行都具有相同的高度,但是当用户单击一行时,所选行应占据整个表高度,其余行应逐渐消失。我只需在所有其他行上设置display:none即可使用它,但我想对转换做一些事情。

我已尝试将max-height设置为100%,然后将其更改为0,但它只会使所选行略大于其余行,而其余行保持不变。我已经尝试将height从100%更改为0,但高度为100%时,顶行是大量的,其余的大约是15px高。

从本质上讲,我想在height:autoheight:0之间进行转换,但这不起作用。所有这一切都是在没有过渡的情况下来回快速进行。关于如何在桌面上进行工作的任何想法?

1 个答案:

答案 0 :(得分:0)

快速Google搜索显示this

.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添加和删除类,所以我没有解释。如果您需要其他帮助,请发布一些代码。祝你好运!

相关问题