如何在背景剪辑中包含文本装饰:文本;影响?
我在锚标记上使用 -webkit-background-clip: text,border
和 color:透明
,下划线似乎永远不可见。
我想要的是将文本装饰包含在背景剪辑中。
这是我的 CSS:
.background-clip {
background: url(images/index-background.jpg) repeat top center fixed;
-webkit-background-clip: text,border;
color: transparent;
}
.background-clip a {
color: transparent;
}
.background-clip a:hover {
text-decoration: underline;
-webkit-text-decorations-in-effect: underline; /* doesn't seem to do anything, I am having trouble finding definitive documentation on this */
}
以及相关的 HTML:
<div class="background-clip"><a href="#">Imagine a lot of text here</a></div>
我在查找 WebKit CSS 属性的完整文档时遇到了很多麻烦。有谁知道我可以做些什么来使文本下划线出现在我的锚标记的悬停上?
I am using -webkit-background-clip: text,border
and color: transparent
on an anchor tag and it seems the underline never becomes visible.
What I want is to include the text decoration in the background clipping.
Here is my CSS:
.background-clip {
background: url(images/index-background.jpg) repeat top center fixed;
-webkit-background-clip: text,border;
color: transparent;
}
.background-clip a {
color: transparent;
}
.background-clip a:hover {
text-decoration: underline;
-webkit-text-decorations-in-effect: underline; /* doesn't seem to do anything, I am having trouble finding definitive documentation on this */
}
And the related HTML:
<div class="background-clip"><a href="#">Imagine a lot of text here</a></div>
I am having a lot of trouble finding thorough documentation of the WebKit CSS properties. Does anyone know what I can do to make the text underline appear on hover of my anchor tag?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以将 -webkit-text-fill-color 更改为 RGBA 值,如下所示;
-webkit-text-fill-color: rgba(0,0,0,0.3);
这允许显示下划线。只需调整不透明度和 RGB 值以匹配背景颜色等即可。You can change your -webkit-text-fill-color to a RGBA value, like so;
-webkit-text-fill-color: rgba(0,0,0,0.3);
This allows the underline to display. Just play around with the opacity and rgb values to match the colour of your background etc.我已经在 Chrome 50.0 和 Firefox Nightly 49.0a1 上对此进行了测试(它还支持
-webkit-background-clip: text
自版本 48.0)据我所知,根据 WebKit 文档,无法在其中包含文本装饰或文本阴影剪报。
根据 Chromium bug
-webkit-text- Decorations-in-effect
的目标是纠正与标准text-decoration
属性相关的继承问题,尽管它显然不会影响-webkit-background-clip: text以任何方式。
I've tested this on Chrome 50.0 and Firefox Nightly 49.0a1 (which also supports
-webkit-background-clip: text
since version 48.0)And as far as I can see, against the WebKit documentation there is no way to include the text decoration or the text shadows in the clipping.
According to a Chromium bug
-webkit-text-decorations-in-effect
targets to correct inheritance issues related to the standardtext-decoration
property, though it obviously doesn't affect-webkit-background-clip: text
in any way.你实际上得到了下划线,但它也有透明的颜色:)
You actually get the underline, but it has a transparent color, too :)
我认为您不能使用
background-clip: text;
显示text-decoration
,但您可以使用一些css
创建下划线>。I don't think you can show the
text-decoration
withbackground-clip: text;
, but you can create your underline playing with somecss
.安德鲁,
如果使用颜色:透明,则看不到下划线。尝试下面的代码,您将在悬停时看到下划线。
Andrew,
You can't see underline if you use color:transparent. Try below code, you will see underline on hover.