gpt4 book ai didi

html - 带有白色文本的线性渐变背景

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

所以我的导航栏中有标题。文字有线性渐变

nav li h1 {
background-image:linear-gradient(90deg,red,#ffae00);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent; }

我希望标题变成白色,背景保持线性渐变

示例:

https://jsfiddle.net/qx96ku4h/

最佳答案

只需将值放回 initial 即可禁用文本渐变并设置文本颜色。

header {
position: fixed;
background: #23262b;
right: 0;
left: 0;
top: 0;
height: 100px;
z-index: 9999;
}

header:after {
content: "";
background: -webkit-linear-gradient(30deg, red, #ffae00);
display: block;
height: 5px;
width: 100%;
position: absolute;
bottom: 0;
}

nav ul {
list-style-type: none;
padding: 0;
margin: -9px;
margin-left: 20px;
}

nav li {
display: inline-block;
position: relative;
text-align: center;
letter-spacing: 1px;
font-weight: 900;
margin: 20px;
}

nav li {
color: white;
text-decoration: none;
text-transform: uppercase;
}


nav li h1 {
background-image: linear-gradient(90deg, red, #ffae00);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
color: #fff;
padding: 20px;
margin: 0;
}

#myBtn:hover h1 {
-webkit-background-clip: initial;
-webkit-text-fill-color: initial;
border-radius: 20px;
}
<header>
<nav>

<ul>
<li onclick="topFunction()" id="myBtn" title="Go to top">
<h1>Make text White</h1>
</li>

</ul>
</nav>
</header>

关于html - 带有白色文本的线性渐变背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54875039/

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