使用CSS在文本中使用线性渐变边框的渐变颜色不起作用 [英] Gradient colour with Linear Gradient Border in text using css not working
本文介绍了使用CSS在文本中使用线性渐变边框的渐变颜色不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用下图设计£1 类似于下图.
I would like design £1 similar to the following image using CSS.
我想在此设计中添加一些带有渐变颜色,渐变边框和文本阴影的文本.我尝试了以下代码,但不起作用.
I would like to have some text with gradient colour, gradient border and text-shadow in this design. I tried the following code, but it doesn't work.
CSS:
.pound-lbl {
background-image: linear-gradient(275deg, #f8e71c 0%, #f8bd1c 100%);
-webkit-background-clip: text;
color: #FFDE17;
text-shadow: 0 2px 4px rgba(0,0,0,0.50);
background: -webkit-linear-gradient(275deg,#F8CC1C 0%, #FFFFFF 100%);
-webkit-background-clip: text;
-webkit-text-stroke: 2px transparent;
}
推荐答案
我认为具有此效果的唯一方法是复制文本.一种将获得笔触颜色,另一种将获得背景颜色:
I think the only way to have this effect is to duplicate the text. One will get the stroke coloration and the other the background coloration:
我使用了不同的颜色来更好地识别它们:
I used different colors to better identify them:
span[data-text] {
display:inline-block;
font-size:90px;
font-weight:bold;
font-family:arial;
position:relative;
margin:10px;
}
span[data-text]:before {
content:attr(data-text);
text-shadow: 0 2px 20px purple;
background: linear-gradient(to bottom,red 0%, blue 100%);
-webkit-text-stroke: 5px transparent;
-webkit-background-clip: text;
background-clip: text;
color:transparent;
}
span[data-text]:after {
content:attr(data-text);
left:0;
top:0;
position:absolute;
background-image: linear-gradient(275deg, green 0%, yellow 100%);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
<span data-text="£1"></span>
这篇关于使用CSS在文本中使用线性渐变边框的渐变颜色不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文