- This topic is empty.
-
AuthorPosts
-
December 19, 2016 at 10:41 pm #249145
Shaan
ParticipantHello,
I’m trying to animate the position and dimensions of a DIV using animation.
Here is my CSS:
div.photo-1 { border: 3px solid #999; border-radius: 14px; overflow: hidden; position: absolute; left: 20vw; top:5vh; height: 10vw; width: 10vw; animation: none 2.3s forwards; -webkit-animation: none 2.3s forwards; -moz-animation: none 2.3s forwards; -o-animation: none 2.3s forwards; z-index: 990; } @keyframes photo-1 { from {left: 20vw; top: 5vh; height:10vw; width:10vw; z-index: 990} to {left: 17.5vw; top:14vh; height: 15vw; width: 15vw; z-index:991} }
I’m changing the animationName to ‘photo-1’ onClick of the DIV element.
I’m changing the animationName property using javascript.document.getElementById('photo-1').animationName = 'photo-1'
This is not working, Could someone please help? Where am I going wrong? Im using Safari 10.0.2 (10602.3.12.0.1)
Many thanks, Dank u!
Shaan van IndeDecember 19, 2016 at 11:36 pm #249146Shikkediel
ParticipantHoi, I think you made a mistake referring to the animation with
none
. That should of course bephoto-1
. It is best to put the default rule, without a browser prefix, as the last one in line by the way.animation: none 2.3s forwards;
animation: photo-1 2.3s forwards;
I’m changing the animationName to ‘photo-1’
I assume you’re adding a class? Can’t see how you would be changing the animation name itself…
December 19, 2016 at 11:42 pm #249147Shaan
ParticipantI’m changing the animationName property using javascript.
document.getElementById(‘photo-1’).animationName = ‘photo-1’December 20, 2016 at 1:04 am #249150Shikkediel
ParticipantOkay, that is a possibility of course. I must’ve missed that. I think it makes more sense to add a class though, any prefixed CSS will otherwise be abundant.
Looks like
.style
is missing in your approach:document.getElementById('photo-1').style.animationName = 'photo-1';
Does the element have an
id
? I only see it being referred to with a classdiv.photo-1
…December 21, 2016 at 6:01 am #249168Shaan
ParticipantHoi Shikkediel,
It works now. I was indeed missing the style before the animationName in the javascript.Thanks! Dank je!
Shaan -
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.