【发布时间】:2018-06-29 07:06:17
【问题描述】:
更新 1:
发现是 CSS 问题,所以我尝试解决这个问题:
.default-details {
.....
margin-top: 107%;
}
@keyframes openning {
from {
margin-top: 107%;
}
to {
margin-top: 0;
}
}
@keyframes closing {
from {
margin-top: 0;
}
to {
margin-top: 107%;
}
}
css:
.default-details {
...
display: none !important;
}
.open-animation {
animation: open 2s ;
}
.close-animation {
animation: close 2s ;
}
@keyframes open {
from {
display: none!important;
margin-top: 107%;
}
to {
margin-top: 0;
display: block;
}
}
@keyframes close {
from {
margin-top: 0;
display: block;
}
to {
display: none !important;
margin-top: 107%;
}
}
预期的行为应该是:
- 点击按钮:详情面板向上滑动,完全覆盖卡片。
- 点击面板:面板向下滑动消失。
(像 Materialise Css Card Reveal 一样:https://react-materialize.github.io/#/cards)
它现在的行为: 它会制作动画,但最后细节面板总是会返回以覆盖卡片。
【问题讨论】:
-
您是否尝试过以另一种方式制作 css 动画?也许这只是一个 CSS 问题,而不是反应问题。你得到“真实之后”的原因是因为 setState 是异步的。所以它不会马上出现。如果您想知道它是否更改,请尝试在您的渲染方法中执行 console.log ......我猜它确实
-
嗨@user222957我试过了,它在回调函数中改变了。那么我应该如何编写css动画?
-
嗨@user222957 你是对的。我删除了动画,只在块和无之间切换显示,它工作正常,但我仍然想要动画效果。请帮忙
标签: javascript css reactjs react-bootstrap