Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS background color keyframes animation

I'm trying to animate a simple fade in/out for a toolbar background color in firefox (themeing). Problem is, my color fades completely out to transparent. I would prefer my color to fade about half way then start easing back to full color.

I listed the code I've tried...

toolbar{
    animation-name: animation;
    animation-duration: 5s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;    
    animation-play-state: running;
}

@keyframes animation {
    50.0%  {background-color:red;}
}

I've tried fiddling around with opacity settings with no luck. Any help is appreciated.

like image 604
user1774640 Avatar asked Jun 23 '14 10:06

user1774640


People also ask

Can you animate background color in CSS?

You can use the CSS3 transition property to smoothly animate the background-color of an element on mouseover, such as a hyperlink or a button.

How do you animate an element in CSS?

An animation lets an element gradually change from one style to another. You can change as many CSS properties you want, as many times as you want. To use CSS animation, you must first specify some keyframes for the animation. Keyframes hold what styles the element will have at certain times.


1 Answers

@-webkit-keyframes animation {
    0%     {background-color:red;}
    50.0%  {background-color:#ff6666;} /* your chosen 'mid' color */
    100.0%  {background-color:red;}
}

@keyframes animation {
    0%     {background-color:red;}
    50.0%  {background-color:#ff6666;}
    100.0%  {background-color:red;}
}

JSfiddle Demo

like image 106
Paulie_D Avatar answered Sep 25 '22 09:09

Paulie_D