Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply CSS properties when transition ends

How do I have the properties of a declaration apply to an element after the CSS3 transitions end? I have something like:

.something {   background: blue;   padding: 10px 0px;   background-clip: content-box;   transition: box-shadow 300ms; } .something:hover {   box-shadow: 0px 0px 3px blue;   padding: 0px;   margin: 10px 0px; } 

I'd like the padding and margin properties in the :hover declaration to be applied after the transition is done in 300ms.

like image 966
Sam Avatar asked May 24 '13 08:05

Sam


People also ask

Which CSS property is used for transition effect?

The transition-property property specifies the name of the CSS property the transition effect is for (the transition effect will start when the specified CSS property changes). Tip: A transition effect could typically occur when a user hover over an element.

How do you stop a transition in CSS?

To trigger an element's transition, toggle a class name on that element that triggers it. To pause an element's transition, use getComputedStyle and getPropertyValue at the point in the transition you want to pause it. Then set those CSS properties of that element equal to those values you just got.

Which property specifies when the transition effect will start?

The transition effect will start when the specified CSS property (width) changes value.

Which CSS property allows you to change property values smoothly over a given duration?

Abstract. CSS Transitions allows property changes in CSS values to occur smoothly over a specified duration.


1 Answers

you can add a delay like this:

transition: box-shadow 300ms;  transition: padding 300ms 400ms; 

the first will start on hover and last 300ms, the second will start after 400ms and again last 300ms.

DEMO

Article on CSS-Tricks

like image 156
Duncan Beattie Avatar answered Sep 18 '22 16:09

Duncan Beattie