CSS firefox 中的变换旋转像素问题
CSS transform rotate pixel issue in firefox
我正在尝试使用变换旋转创建摆动按钮 属性,
它在 Opera 和 chrome 浏览器中工作正常,但在 Firefox 中它在按钮的边框中产生奇怪的像素问题:
我的 css 按钮和摆动关键帧代码
.RedButton {
background-color: #bc0000;
border-radius: 7px;
border: 1px solid #bc0000;
display: inline-block;
cursor: pointer;
color: #fff !important;
font-family: Arial;
font-size: 30px;
font-weight: bold;
padding: 7px 24px;
text-decoration: none;
margin-top: 15px;
animation: swing 5s infinite;
-moz-animation: swing 5s infinite;
transition: 0.2s;
-moz-transition: 0.2s;
}
@-moz-keyframes swing {
20%,
60% {
-moz-transform: rotate(5deg);
}
40%,
80% {
-moz-transform: rotate(-5deg);
}
100% {
-moz-transform: rotate(0deg);
}
}
@keyframes swing {
20%,
60% {
transform: rotate(5deg);
}
40%,
80% {
transform: rotate(-5deg);
}
100% {
transform: rotate(0deg);
}
}
<div class="RedButton">Get Started Now!</div>
我是不是漏掉了什么?
backface-visibility
似乎根据这个 SO 线程来完成工作:css transform, jagged edges in chrome
.RedButton {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
backface-visibility: hidden;
// ...
}
如果这不起作用,请尝试:outline: 1px solid transparent;
添加一个小阴影使其看起来更好:
.RedButton {
background-color: #bc0000;
border-radius: 7px;
border: 1px solid #bc0000;
display: inline-block;
cursor: pointer;
color: #fff ;
font-family: Arial;
font-size: 30px;
font-weight: bold;
padding: 7px 24px;
text-decoration: none;
margin-top: 15px;
animation: swing 5s infinite;
box-shadow: 0 0 1px #bc0000;
}
@keyframes swing {
20%,
60% {
transform: rotate(5deg);
}
40%,
80% {
transform: rotate(-5deg);
}
}
<div class="RedButton">Get Started Now!</div>
我正在尝试使用变换旋转创建摆动按钮 属性, 它在 Opera 和 chrome 浏览器中工作正常,但在 Firefox 中它在按钮的边框中产生奇怪的像素问题:
我的 css 按钮和摆动关键帧代码
.RedButton {
background-color: #bc0000;
border-radius: 7px;
border: 1px solid #bc0000;
display: inline-block;
cursor: pointer;
color: #fff !important;
font-family: Arial;
font-size: 30px;
font-weight: bold;
padding: 7px 24px;
text-decoration: none;
margin-top: 15px;
animation: swing 5s infinite;
-moz-animation: swing 5s infinite;
transition: 0.2s;
-moz-transition: 0.2s;
}
@-moz-keyframes swing {
20%,
60% {
-moz-transform: rotate(5deg);
}
40%,
80% {
-moz-transform: rotate(-5deg);
}
100% {
-moz-transform: rotate(0deg);
}
}
@keyframes swing {
20%,
60% {
transform: rotate(5deg);
}
40%,
80% {
transform: rotate(-5deg);
}
100% {
transform: rotate(0deg);
}
}
<div class="RedButton">Get Started Now!</div>
我是不是漏掉了什么?
backface-visibility
似乎根据这个 SO 线程来完成工作:css transform, jagged edges in chrome
.RedButton {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
backface-visibility: hidden;
// ...
}
如果这不起作用,请尝试:outline: 1px solid transparent;
添加一个小阴影使其看起来更好:
.RedButton {
background-color: #bc0000;
border-radius: 7px;
border: 1px solid #bc0000;
display: inline-block;
cursor: pointer;
color: #fff ;
font-family: Arial;
font-size: 30px;
font-weight: bold;
padding: 7px 24px;
text-decoration: none;
margin-top: 15px;
animation: swing 5s infinite;
box-shadow: 0 0 1px #bc0000;
}
@keyframes swing {
20%,
60% {
transform: rotate(5deg);
}
40%,
80% {
transform: rotate(-5deg);
}
}
<div class="RedButton">Get Started Now!</div>