[英]Is there a way to move a html element from a div to another div using react?
how to move a HTML element from a div to another div element in React.如何将 HTML 元素从 div 移动到 React 中的另一个 div 元素。
I want an animation when an element moves from one div to another.当元素从一个 div 移动到另一个 div 时,我想要一个 animation。 If it can be done please suggest steps.如果可以,请提出步骤。
My suggestion would be我的建议是
If you want to get fancy and want an actual animation of the element moving, I'd suggest doing something like this:如果您想花哨并想要一个实际的 animation 元素移动,我建议您这样做:
#element{
animation: move 10s;
-moz-animation: move 10s;
/* Firefox */
-webkit-animation: move 10s;
/* Safari and Chrome */
-o-animation: move 10s;
/* Opera */
}
@keyframes move {
0%{
position: absolute;
bottom: 20px;
}
50%{
position: absolute;
bottom: 80px;
}
100%{
position: absolute;
bottom: 140px;
}
@-moz-keyframes move {
/* Firefox */
0%{
position: absolute;
bottom: 20px;
}
50%{
position: absolute;
bottom: 80px;
}
100%{
position: absolute;
bottom: 140px;
}
}
@-webkit-keyframes move {
/* Safari and Chrome */
0%{
position: absolute;
bottom: 20px;
}
50%{
position: absolute;
bottom: 80px;
}
100%{
position: absolute;
bottom: 140px;
}
}
@-o-keyframes move {
/* Opera */
0%{
position: absolute;
bottom: 20px;
}
50%{
position: absolute;
bottom: 80px;
}
100%{
position: absolute;
bottom: 140px;
}
}
You might need to play around with the positioning and timing, but something like this can make an element start moving as soon as it's created in React.您可能需要调整定位和时间,但是这样的事情可以使元素在 React 中创建后立即开始移动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.