gpt4 book ai didi

css - 使用带有动画渐变的文本阴影

转载 作者:行者123 更新时间:2023-11-28 00:52:46 25 4
gpt4 key购买 nike

因此,我尝试将白色文本阴影/轮廓添加到我的动画渐变中,但每当我这样做时,文本都会变成全白并且渐变不适用。

如果有人能帮助我,那将不胜感激

渐变代码:

.linear-wipe {

background: linear-gradient(to right, #00008B 15%, red 35%, red 50%, #00008B 70%);
background-size: 200% auto;

background-clip: text;
text-fill-color: transparent;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;

animation: shine 5s linear infinite;
}
@keyframes shine {
to {
background-position: 200% center;
}
}

阴影/大纲代码:

text-shadow: 
-0.2px 0px 1px white,
0px 0.2px 1px white,
0.2px 0px 1px white,
0px -0.2px 1px white;

你可以在这里看到问题。如果删除“text-shadow”位,渐变效果很好,但有了它,文本就会变成白色: https://codepen.io/anon/pen/wQvexd

最佳答案

如果要为渐变文本设置 text-shadow,请使用 after 伪元素;

这里我试过一些东西

body{
background-color:black;
}
.linear-wipe {

background: linear-gradient(to right, #00008B 15%, red 35%, red 50%, #00008B 70%);
background-size: 200% auto;
background-clip: text;
text-fill-color: transparent;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
position:absolute;
animation: shine 5s linear infinite;
}

.linear-wipe:after {
background: none;
content: attr(data-text);
left: 0;
position: absolute;
text-shadow:
-0.2px 0px 1px white,
0px 0.2px 1px white,
0.2px 0px 1px white,
0px -0.2px 1px white;
top: 0;
z-index: -1;
}
@keyframes shine {
to {
background-position: 200% center;
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<h1 class="linear-wipe" data-text="Hello World">Hello World</h1>
</body>
</html>

关于css - 使用带有动画渐变的文本阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53130633/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com