3

I have realized that I can't simple accomplish the same code below by separating by coma @keyframes mymove, @-moz-keyframes mymove, etc... In order for them to work I need to declare it each one separately as below.

Is there any way to group them and make this code shorter?

@keyframes mymove
{
from {top:0px;}
to {top:200px;}
}

@-moz-keyframes mymove /* Firefox */
{
from {top:0px;}
to {top:200px;}
}

@-webkit-keyframes mymove /* Safari and Chrome */
{
from {top:0px;}
to {top:200px;}
}

1 Answer 1

4

no, I don't think so, but you could use a CSS language (aka CSS preprocessor) like SASS/SCSS/LESS/... - the output (CSS) would still be the same, but changing something would be much easier!

Check out

if you're interested - the effort of installing them and setting them up is totally worth it!

EDIT: Using SCSS I did the following:

@mixin keyframes($name) {
    @-webkit-keyframes #{$name} { @content; }
    @-moz-keyframes #{$name} { @content; }
    @keyframes #{$name} { @content; }
}

example of usage:

@include keyframes(pulse) {
    0%,100% {
        opacity: 0;
    } 
    50% {
        opacity: 1;
    }
}

Although it should be added that you need the latest pre-release of SASS to be able to nest rules (we have got a "{" inside another "{" rule...) so you should update run "gem install sass --pre" which should get you "sass-3.2.0.alpha.104"

Sign up to request clarification or add additional context in comments.

1 Comment

I'm already using Compass and SASS. But i'm not sure they have a method for this besides their experimental extension. compass-style.org/reference/compass/css3/shared

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.