Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a short way to list CSS3 keyframes with vendor prefixes?

At the moment I have to list all variations:

@-webkit-keyframes show {
    from { background-color: rgba(0, 0, 0, 0); }
    to { background-color: rgba(0, 0, 0, 0.8); }
}

@-moz-keyframes show {
    from { background-color: rgba(0, 0, 0, 0); }
    to { background-color: rgba(0, 0, 0, 0.8); }
}

[…]

You get the idea. Is there any way to write this shorter? Something like this that is not breaking it:

@-webkit-keyframes show, @-moz-keyframes show {}
like image 939
insertusernamehere Avatar asked Mar 12 '13 14:03

insertusernamehere


1 Answers

Not natively in CSS but you can accomplish this by using a CSS preprocessor, for example LESS which supports the concept of "mixins" to remove some duplication.

More info can be found here, specifically the example from the article:

@-webkit-keyframes some-animation {.mixi-frames;}
@-moz-keyframes some-animation {.mixi-frames;}

.mixi-frames () {
    from {width: 254px;}
    to {width: 512px;}
}
like image 160
andyb Avatar answered Oct 17 '22 23:10

andyb