2017-12-18 35 views
0

尝试使用WebKit的文本填充色动画-webkit-文本填充色

a { 
    color: #fff; 
    -webkit-text-fill-color: rgba(255,255,255,0); 
    -webkit-text-stroke-width: 2px; 
    -webkit-text-stroke-color: #fff; 
    -webkit-text-stroke: 2px white; 
    -webkit-transition: all .5s ease-out; 
    -moz-transition: all .5s ease-out; 
    -o-transition: all .5s ease-out; 
    transition: all .5s ease-out; 
    } 
a:hover { 
    -webkit-text-fill-color: rgba(255,255,255,1); 
} 

我不能将颜色设置为透明,因为-webkit的兼容性问题动画文本的透明度在IE上使用-text-fill-color和-webkit-text-stroke。

+0

如果你的背景是半固体,你可以用'文本shadow'和'颜色'为ie fallback –

+0

无法使用文字 - 阴影,主要背景是图片 –

+0

我认为更简单的解决方案是检测ie和边缘14并覆盖和覆盖这些元素的颜色风格,您怎么看? –

回答

0

对不起,我没有IE浏览器来测试它在我的Mac,请试试这个代码

a { 
 
    
 
    color: #d5d5d5; 
 
    -webkit-text-fill-color: rgba(225,255,255,0); 
 
    -webkit-text-stroke-width: 2px; 
 
    -webkit-text-stroke-color: #d5d5d5; 
 
    -webkit-text-stroke: 2px #d5d5d5; 
 
    -webkit-transition: all .5s ease-out; 
 
-moz-transition: all .5s ease-out; /*gecko*/ 
 
-ms-transition: all .5s ease-out; /*IE10*/ 
 
-o-transition: all .5s ease-out; /*opera 11.10+*/ 
 
-pie-transition: all .5s ease-out; /*PIE*/ 
 
    transition: all .5s ease-out; 
 
    } 
 
a:hover { 
 
    color: #000; 
 
    -webkit-text-fill-color: rgba(255,255,255,1); 
 
    -webkit-text-stroke-width: 2px; 
 
    -webkit-text-stroke-color: #000; 
 
-moz-transition: all .5s ease-out; /*gecko*/ 
 
-ms-transition: all .5s ease-out; /*IE10*/ 
 
-o-transition: all .5s ease-out; /*opera 11.10+*/ 
 
-pie-transition: all .5s ease-out; /*PIE*/ 
 
    transition: all .5s ease-out; 
 
}
<a href="#">Test</a>

+0

这是我的第一个方法,在IE上工作正常,但它不在Edge上-v14,-webkit-text-stroke-color正在覆盖颜色,但是因为-webkit-text-stroke没有引入,直到v15没有文本显示。谢谢 –

+0

只是。别。机械地尝试任何已知的供应商前缀,希望某些组合可以偶然使用。自2012年起,Web不能像这样工作,当时供应商前缀不再是供应商。现在没有真正的浏览器需要'-o-'来做任何事情,'-moz-'除了某些形式控制调整之外什么都需要。请使用Autoprefixer代替。 –