Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 transitions want to add a colour and fade it away

Tags:

I want to make a DIV background (which doesn't have a background color) flash red then ease out to blank again. now I have used JS to add a new CLASS (which adds the red) to the DIV in question and CSS3 to add an easing to the background color. but it eases it IN, what I want is it to go RED then ease out. I guess I could do this by using JS to add multiple CLasss after a delay. but can CSS3 be used to do this entirely?

like image 763
Purplemonkey Avatar asked Apr 09 '12 12:04

Purplemonkey


People also ask

How do you add transition effects in css3?

To make the transition occur, you must specify at least two things — the name of the CSS property to which you want to apply the transition effect using the transition-property CSS property, and the duration of the transition effect (greater than 0) using the transition-duration CSS property.

How do I fade background color in CSS?

So, here's how to create a background blur using the backdrop-filter CSS property. backdrop-filter: blur(5px);


1 Answers

If you want something like a highlighting you may want to use CSS3 animations. They are not supported in older browsers. Check caniuse for this.

The highlight is called on clicking the link. Here is the CSS (without vendor-prefixes):

@keyframes highlight {     0% {         background: red     }     100% {         background: none;     } }  #highlight:target {     animation: highlight 1s; }
<div id="highlight"><a href="#highlight">Highlight</a></div>
like image 189
drublic Avatar answered Sep 23 '22 18:09

drublic