如何在所有主流浏览器中制作透明文本

时间:2018-09-11 01:10:33

标签: html css3

在浏览器中制作透明文本时遇到麻烦。这是一个片段

.title {
      margin-bottom: 15px;
      font-family: "Open Sans";
      font-size: 87px;
      font-weight: 800;
      line-height: 1;
      color: #fff;
      text-transform: uppercase;
      background:    -moz-linear-gradient(to left,rgba(0,0,0,0) 0,rgba(255,255,255,0.8) 50%,#fff 100%);
      background: -webkit-linear-gradient(to left,rgba(0,0,0,0) 0,rgba(255,255,255,0.8) 50%,#fff 100%);
      background:         linear-gradient(to left,rgba(0,0,0,0) 0,rgba(255,255,255,0.8) 50%,#fff 100%);
      -webkit-background-clip: text;

      -webkit-text-fill-color: transparent;
    }

结果是:

Success image

但是在IE 11中,无法解决该问题?有什么建议吗?

Failure

1 个答案:

答案 0 :(得分:0)

对于IE10 +,您可以尝试使用-ms-linear-gradient

background: rgba(0,0,0,1);/* Old Browsers */
background: -moz-linear-gradient(left, rgba(0,0,0,1) 0%, rgba(255,255,255,0.5) 100%); /* FF3.6+ */
background: -webkit-gradient(left top, right top, color-stop(0%, rgba(0,0,0,1)), color-stop(100%, rgba(255,255,255,0.5)));/* Chrome, Safari4+ */
background: -webkit-linear-gradient(left, rgba(0,0,0,1) 0%, rgba(255,255,255,0.5) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(0,0,0,1) 0%, rgba(255,255,255,0.5) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(0,0,0,1) 0%, rgba(255,255,255,0.5) 100%); /* IE 10+ */
background: linear-gradient(to right, rgba(0,0,0,1) 0%, rgba(255,255,255,0.5) 100%);/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#ffffff', GradientType=1 );/* IE6-9 */

如果愿意,可以在此工具中创建以下代码:

https://www.cssmatic.com/gradient-generator