- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Smooth CSS animate via addClass/removeClass
I am trying to animate via CSS by adding and removing classes.
click > addClass works smoothly
But on toggle/removeClass there is no smooth transition and the whole thing snaps back to default.
Can some one please explain and help me out here.
I think, without going into it too far that the div doesn’t have room to move inside
Hello,
Are you using the same codepen?
http://codepen.io/TheEnd/pen/YPVOMR?editors=110
There seems to be a big difference in the CSS:
.animaContX {
height: 250px;
position: relative;
margin: 10% auto;
border:1px solid red;
}
VS
.animaContX {
width: 45px;
position: relative;
margin: 10% auto;
}
Can some one help me?
No, I adapted yours to show one possible reason why yours did not work.
As you can see, the JS and animation work provided the element has enough space around it.
What the actual solution is I did not have time to go into.