我有以下CSS规则
*.highlight {
@-webkit-keyframes blink {
0% {
outline: 5px solid rgba(0, 0, 0, 0);
}
50% {
outline: 5px solid red;
}
100% {
outline: 5px solid rgba(0, 0, 0, 0);
}
}
@keyframes blink {
0% {
outline: 5px solid rgba(0, 0, 0, 0);
}
50% {
outline: 5px solid red;
}
100% {
outline: 5px solid rgba(0, 0, 0, 0);
}
}
animation: blink normal 1.5s infinite ease-in-out;
-webkit-animation-name: blink;
-webkit-animation-duration: 1.5s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: ease-in-out;
box-sizing: border-box;
}
除了safari之外,在所有浏览器中均可正常使用。我用google搜索和谷歌搜索,所有类似的答案我发现围绕变换,我不使用(至少在这里)任何人都可以帮助吗?
答案 0 :(得分:0)
感谢@Joseph Silber在之前的回答中的回答,我设法通过改变轮廓颜色而不是整个轮廓来实现它(见下文)。
@-webkit-keyframes blink {
0% {
outline-color: transparent;
}
50% {
outline-color: red;
}
100% {
outline-color: transparent;
}
}
@keyframes blink {
0% {
outline-color: transparent;
}
50% {
outline-color: red;
}
100% {
outline-color: transparent;
}
}
*.highlight {
animation: blink normal 1.5s infinite ease-in-out;
-webkit-animation-name: blink;
-webkit-animation-duration: 1.5s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: ease-in-out;
outline: 5px solid red;
box-sizing: border-box;
}