CSS中文字的背景图片在Mozilla浏览器上无法正常显示

3
以下代码在Chrome上运行完美,但在Mozilla上不起作用,请尽快检查并回复,提前致谢。 我的HTML代码如下:
<div class="about-bg">        
   <div class="about-us-heading">About<br>The Apes</div>
</div>

我的CSS代码:

.about-bg {
    background-color: #fff;
    float: left;
    margin-right: 90px;
    padding: 80px 20px 40px 0;
}
.about-us-heading {
    font-size: 92px;
    text-transform: uppercase;
    font-family: 'Lato', sans-serif;
    font-weight: 900;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-image: url("http://creativeapes.net/wp-content/uploads/2016/02/building-back.jpg");
    background-position: -1px -82px;
    background-repeat: no-repeat;
    line-height: 95px;
}

这是我的网站链接:http://creativeapes.net/#about-us,与IT技术有关。
2个回答

1

SVG 可能是一个选择:https://sarasoueidan.com/blog/css-svg-clipping/但我会创建一个 PNG 图片。 - Paul Smith

0

如果您想使用background-clip: text,它只在基于WebKit的浏览器中可用,而在Firefox中不可用。因此,您可以使用此polyfill - https://github.com/TimPietrusky/background-clip-text-polyfill

它在Firefox中完美运行,并用SVG替换指定的dom元素。唯一的问题是SVG文本无法使用换行符,因此您的内容将在一行中显示。

var element = document.querySelector('.myelement'); 

/*
 * Call the polyfill
 *
 * patternID : the unique ID of the SVG pattern
 * patternURL : the URL to the background-image
 * class : the css-class applied to the SVG
 */
element.backgroundClipPolyfill({
  'patternID' : 'mypattern',
  'patternURL' : 'url/to/your/pattern',
  'class' : 'myelement'
});

这里有一个实时示例:http://codepen.io/TimPietrusky/pen/cnvBk


@MuhammadUmerShaikh 没有关系,顺便说一下,如果我的回答对您有帮助,您可以投票并接受我的答案 :) - johannesMatevosyan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接