Learning coding means GreatToCode Be more than a Coder ! Greattocode , Join GreatToCode Community,1000+ Students Trusted On Us .If You want to learn coding, Then GreatToCode Help You.No matter what It Takes !


CODE YOUR WAY TO A MORE FULFILLING And HIGHER PAYING CAREER IN TECH, START CODING FOR FREE Camp With GreatToCode - Join the Thousands learning to code with GreatToCode
Interactive online coding classes for at-home learning with GreatToCode . Try ₹Free Per Month Coding Classes With The Top Teachers . Animation in CSS

Animation in CSS

CSS animations allow you to create dynamic and visually appealing effects on your web pages. Here's a basic example of how to create animations in CSS:

**Using `@keyframes` for Animations:**

```css
/* Define the animation */
@keyframes slide {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(200px);
    }
}

/* Apply the animation to an element */
.animated-element {
    width: 100px;
    height: 100px;
    background-color: blue;
    animation: slide 2s ease-in-out infinite;
}
```

In the example above:
- `@keyframes slide`: Defines the animation called "slide."
- `0%` and `100%`: These are keyframe points defining the animation's start and end states.
- `transform: translateX(0)` and `transform: translateX(200px)`: These specify the transformation at the keyframes.
- `.animated-element`: The class applied to the HTML element you want to animate.
- `animation: slide 2s ease-in-out infinite;`: Applies the "slide" animation, running for 2 seconds with an ease-in-out timing function, and repeating infinitely.

**Using `animation` Property:**

You can also use the `animation` property with separate animation values:

```css
.animated-element {
    width: 100px;
    height: 100px;
    background-color: blue;
    animation-name: slide;
    animation-duration: 2s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}
```

**Multiple Animations:**

You can combine multiple animations as well:

```css
@keyframes fadeAndSlide {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.animated-element {
    animation: fadeAndSlide 1s ease-out, slide 2s ease-in-out infinite;
}
```

In this example, both the "fadeAndSlide" and "slide" animations will be applied to the `.animated-element`.

Remember that these are basic examples. CSS animations can be as simple or complex as you want them to be, with various properties like delays, keyframe percentages, and more. You can also explore CSS transitions for smoother property changes.

Post a Comment

0 Comments

•Give The opportunity to your child with GreatToCode Kid's • Online Coding Classes for Your Kid • Introduce Your kid To the world's of coding
•Fuel You Career with our 100+ Hiring Partners, Advance Your Career in Tech with GreatToCode. •Join The Largest Tech and coding Community and Fast Forward Your career with GreatToCode. •10000+ Learner's+ 90 % placement Guarantee. • Learning Coding is Better with the GreatToCode community .
•Greattocode Kid's •GreatToCode Career •GreatToCode Interview •GreatToCode Professional •GreatToCode for schools •GreatToCode For colleges •GreatToCods For Businesses.
Are you ready to join the millions of people learning to code? GreatToCode Pass is your one-stop-shop to get access to 1000+ courses, top-notch support, and successful job placement. What are you waiting for? Sign up now and get your future in motion with GreatToCode Pass.