gpt4 book ai didi

css - @keyframes 将不同的浏览器版本合并为一个

转载 作者:行者123 更新时间:2023-11-28 10:47:17 26 4
gpt4 key购买 nike

是否可以减少代码以生成一组可以处理各种浏览器前缀的混合宏?

尝试减少代码长度以使用更多mixin

所以代替

@-moz-keyframes orbit {
0% {
opacity: 1;
z-index:99;
-moz-transform: rotate(180deg);
-moz-animation-timing-function: ease-out;
}
}

@-ms-keyframes orbit {
0% {
opacity: 1;
z-index:99;
-ms-transform: rotate(180deg);
-ms-animation-timing-function: ease-out;
}
}


@-o-keyframes orbit {
0% {
opacity: 1;
z-index:99;
-o-transform: rotate(180deg);
-o-animation-timing-function: ease-out;
}
}

@-webkit-keyframes orbit {
0% {
opacity: 1;
z-index:99;
-webkit-transform: rotate(180deg);
-webkit-animation-timing-function: ease-out;
}
}

我们还有类似的东西吗?

@keyframes orbit {
0% {
opacity: 1;
z-index:99;
-moz-transform: rotate(180deg);
-moz-animation-timing-function: ease-out;

-o-transform: rotate(180deg);
-o-animation-timing-function: ease-out;

-ms-transform: rotate(180deg);
-ms-animation-timing-function: ease-out;

-webkit-transform: rotate(180deg);
-webkit-animation-timing-function: ease-out;

transform: rotate(180deg);
animation-timing-function: ease-out;
}
}

最佳答案

在 SASS 中你可以使用这个模板:

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

它应该让你开始!

关于css - @keyframes 将不同的浏览器版本合并为一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25785316/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com