css-protips icon indicating copy to clipboard operation
css-protips copied to clipboard

Animation to any element

Open GemmieDodger opened this issue 5 years ago • 5 comments

Hi,

Please can I add an animation on load, which can be added to any element via. a class.

@keyframes slideInFromLeft { 0% { transform: translateX(-100%); } 100% { transform: translateX(0); } }

.animation-element-onload { animation: 1s ease-out 0s 1 slideInFromLeft; }

Thank you, Gemma

GemmieDodger avatar Jun 05 '20 12:06 GemmieDodger

Sure, do you have a demo example showing this? Feel free to submit a pull request with your recommendation. Please add a sentence or two explaining why this would be a good "pro" tip. More information on submitting is in the contribution guidelines.

AllThingsSmitty avatar Jun 05 '20 13:06 AllThingsSmitty

Here's a codepen. https://codepen.io/gemmiedodger/pen/gOPbZyg

I'll have a read of the guidelines, thank you. This is my first ever contribution so please let me know if I do something wrong!

GemmieDodger avatar Jun 05 '20 13:06 GemmieDodger

Anyway to add animations onScroll? Without the use of an external script or library?

ghost avatar Jul 21 '20 07:07 ghost

@GemmieDodger
You can run a CSS animation on page load without using any JavaScript. You just have to use CSS3 Keyframes. Try using Keyframe animations it would work .

v007rj avatar Feb 09 '21 10:02 v007rj

You can try adding to your code. In the div class you want to animate, you just need to add -> data-aos="fade-left"(for example). You can make required changes like offset, delay, duration, etc. like this

Please follow this link for the full description of using this method. https://github.com/michalsnik/aos

ankit11hab avatar Feb 10 '21 15:02 ankit11hab