Användning av vendor-prefix för att skapa animation i LESS
Låt oss skapa en funktion som implementerar
det cross-browser kommandot @keyframes:
.keyframes(@name, @code) {
@-o-keyframes @name {@code();}
@-moz-keyframes @name {@code();}
@-webkit-keyframes @name {@code();}
@keyframes @name {@code();}
}
Låt oss använda vår funktion:
.keyframes(anim, {
from {
width: 100px;
}
to {
width: 200px;
}
}
);
Resultat av kompilering:
@-o-keyframes anim {
from {
width: 100px;
}
to {
width: 200px;
}
}
@-moz-keyframes anim {
from {
width: 100px;
}
to {
width: 200px;
}
}
@-webkit-keyframes anim {
from {
width: 100px;
}
to {
width: 200px;
}
}
@keyframes anim {
from {
width: 100px;
}
to {
width: 200px;
}
}