Tem*_*fif 13
在单色顶部使用背面/白色图层作为渐变
html {
background:
linear-gradient(90deg,rgb(255 255 255/50%),rgb(0 0 0/50%)),
red; /* here is your single color */
}Run Code Online (Sandbox Code Playgroud)
另一个想法是用color-mix()相同的颜色创建不同的色调
html {
--c: red; /* the main color */
background:
linear-gradient(90deg,
color-mix(in srgb,var(--c), #fff 30%), /* we mix with white for brighter */
color-mix(in srgb,var(--c), #000 30%) /* we mix with black for darker */
)
} Run Code Online (Sandbox Code Playgroud)
您可以使用 Alpha 通道来实现此目的。考虑颜色“#428383”:
div {
background-color: #428383; /* for browsers without gradient support */
background: linear-gradient(#42838344, #428383ff);
width: 100px;
height: 100px;
}Run Code Online (Sandbox Code Playgroud)
<div></div>Run Code Online (Sandbox Code Playgroud)