Áp dụng tiền tố nhà cung cấp (vendor prefix) để tạo animation trong LESS
Hãy tạo một hàm thực hiện lệnh @keyframes đa trình duyệt:
.keyframes(@name, @code) {
@-o-keyframes @name {@code();}
@-moz-keyframes @name {@code();}
@-webkit-keyframes @name {@code();}
@keyframes @name {@code();}
}
Sử dụng hàm của chúng ta:
.keyframes(anim, {
from {
width: 100px;
}
to {
width: 200px;
}
}
);
Kết quả biên dịch:
@-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;
}
}