简体   繁体   English

多行CSS渐变文本不起作用

[英]Multi-line CSS gradient text not working

I'm writing a theme for WordPress and am making use of Webkit text gradients for links. 我正在为WordPress编写主题,并且正在使用Webkit文本渐变进行链接。 It's working so far, but as soon as the link wraps around to the next line, only the top half of the link is visible. 到目前为止,它已经可以使用了,但是一旦链接回绕到下一行,就只能看到链接的上半部分。

Example code: 示例代码:

 #page a:link { background: -webkit-repeating-linear-gradient(top, #cade43, #8a953e) !important; -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important; font-weight: bold; } #page { background: black; width: 100px; } 
 <div id="page"> <a href="#">This is a long link that stretches over two lines</a> </div> 

JSFiddle of the example: https://jsfiddle.net/6ap3j5o5/2/ JSFiddle示例: https ://jsfiddle.net/6ap3j5o5/2/

JSFiddle示例。选择底部两行以显示它们确实存在

The image above is what appears in my browser (Chrome 43.0.2357.37 beta-m). 上图是我的浏览器(Chrome 43.0.2357.37 beta-m)中显示的图像。 I've selected the last two lines with the cursor to show that they do exist and aren't cut off by the DIV 我已经用光标选择了最后两行,以表明它们确实存在并且未被DIV切断

What can I do to fix this? 我该怎么做才能解决此问题?

As a workaround, you could make the link <a> as inline-block or block level. 解决方法是,可以将链接<a>设为inline-blockblock级别。

 #page a:link { background: -webkit-repeating-linear-gradient(top, #cade43, #8a953e) !important; -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important; font-weight: bold; display: inline-block; /*or block*/ } #page { background: black; width: 100px; } 
 <div id="page"> <a href="#">This is a long link that stretches over two lines</a> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM