

Meaning, you could have it move up along the Y-axis, but you couldn't specify it to move back down the Y-axis to complete its bounce. That's because you can only specific the initial and end state of the transitioning element - not an intermediate point. You may have noticed already that it would not be possible to create a bounce effect using the transition property. See the Pen Bounce on Hover by Christina Perricone ( on CodePen.

At 100%, or the end of the animation sequence, it will return to where it started on the Y-axis, completing its bounce. At 50%, or halfway through the animation sequence, the element will move 100px up the Y-axis. At 0%, or the first moment of the animation sequence, the element will be at 0px along the Y-axis. The first will set the initial state of the animation. I'll also set its timing to ease so that the animation starts out slow, speeds up, and then slows down.įinally, I'll define three keyframes. Then I'll define the animation to complete its bounce in two seconds and run infinitely (as long as the user continues to hover over the div). That way it will only bounce in that defined container area and not overlap with the heading or paragraph. In the example below, I'll place the div in a flex container.
#Disable animate it css how to
We'll walk through how to create an animation step-by-step later in this post for now, we'll just briefly talk through this example. All you have to do is define some animation properties and keyframes. To grab your website visitor's attention, you can create a bounce effect when a user hovers over an element.

Let's take a look at a bounce animation below. In other words, each keyframe describes how the animated element should render at a given time during the animation sequence. Keyframes indicate the start and end of the animation, as well as any intermediate steps between the start and end. You can't specify any intermediate points, and the transition can only run once.Īnimations, on the other hand, can loop, repeat backwards, and move from an initial state to intermediate states to an end state, thanks to keyframes. Once triggered, transitions can only move from an initial state to a final state. Transitions allow you to alter the behavior and appearance of an element - but only when there's a trigger, like a user hovering over the element. The two terms are often used interchangeably, but animations and transitions are different. While this looks like an animation, it's actually a transition. See the Pen CSS Transition on Hover by HubSpot ( on CodePen. If you hover over the div, it will gradually change from light pink to dark pink. It's used to highlight key items on a web page and it's an effective way to enhance your site's interactivity. What is a CSS hover animation?Ī CSS hover animation occurs when a user hovers over an element, and the element responds with motion or another transition effect. In this post, we'll provide everything you need to know about how to create an animation or transition on hover, including some examples that you can use on your website. Of the pseudo-classes above, :hover is the most common. :target - when a user clicks on a different element.:active - when a user clicks on the element.:focus - when a user clicks or taps the element, or selects it with the Tab key of their keyboard.:hover - when a user hovers over the element.Only in that state will the element change from one style to another. That means creating this interactivity is both simpler and less expensive than it used to be.īoth the CSS animation and transition properties can be specified with pseudo-classes, which define a special state of the element. Thanks to CSS, front-end developers can now design animations and transitions without JavaScript or Flash.
