在 CSS 应用过滤器/戴口罩?
Apply filter / wear mask in CSS?
预期结果:
我设法得到了什么:
请尽量不要给我绝对值,因为我希望网站能够响应。文本和背景分隔线应始终位于中心。文本应根据每个字符的位置根据需要更改其颜色。
提前致谢!
我的Html代码:
<div class="bg"></div>
<header>Plants</header>
<h1>Fresh Plants <br> for You.</h1>
我的CSS:
header {
font-size: 1.5rem;
text-transform: uppercase;
color: white;
margin-top: 30px;
margin-left: 40px;
}
.bg {
position: absolute;
top: 0;
left: 0;
z-index: -1;
background: linear-gradient(90deg, rgba(31,171,137,1) 0%, rgba(31,171,137,1) 50%, rgba(157,243,196,1) 50%, rgba(157,243,196,1) 100%);
height: 52rem;
width: 100%;
}
h1 {
font-size: 5rem;
/*color: white;*/
margin-left: 30.2rem;
font-weight: 700;
background-clip: text;
-webkit-background-clip: text;
color: rgba(255,255,255,1);
/*background: linear-gradient(90deg, rgba(31,171,137,1) 0%, rgba(31,171,137,1) 50%, rgba(157,243,196,1) 50%, rgba(157,243,196,1) 100%);*/
}
因为它是一个 90deg
方向使两个背景都 fixed
所以他们都将屏幕作为参考:
header {
font-size: 1.5rem;
text-transform: uppercase;
color: white;
margin-top: 30px;
margin-left: 40px;
}
.bg {
position: absolute;
top: 0;
left: 0;
z-index: -1;
background: linear-gradient(90deg, rgba(31, 171, 137, 1) 50%, rgba(157, 243, 196, 1) 0) fixed;
height: 52rem;
width: 100%;
}
h1 {
font-size: 5rem;
font-weight: 700;
text-align:center;
color: #0000;
background: linear-gradient(90deg, #fff 50%, blue 0) fixed;
background-clip: text;
-webkit-background-clip: text;
}
<div class="bg"></div>
<header>Plants</header>
<h1>Fresh Plants <br> for You.</h1>
预期结果:
我设法得到了什么:
请尽量不要给我绝对值,因为我希望网站能够响应。文本和背景分隔线应始终位于中心。文本应根据每个字符的位置根据需要更改其颜色。 提前致谢!
我的Html代码:
<div class="bg"></div>
<header>Plants</header>
<h1>Fresh Plants <br> for You.</h1>
我的CSS:
header {
font-size: 1.5rem;
text-transform: uppercase;
color: white;
margin-top: 30px;
margin-left: 40px;
}
.bg {
position: absolute;
top: 0;
left: 0;
z-index: -1;
background: linear-gradient(90deg, rgba(31,171,137,1) 0%, rgba(31,171,137,1) 50%, rgba(157,243,196,1) 50%, rgba(157,243,196,1) 100%);
height: 52rem;
width: 100%;
}
h1 {
font-size: 5rem;
/*color: white;*/
margin-left: 30.2rem;
font-weight: 700;
background-clip: text;
-webkit-background-clip: text;
color: rgba(255,255,255,1);
/*background: linear-gradient(90deg, rgba(31,171,137,1) 0%, rgba(31,171,137,1) 50%, rgba(157,243,196,1) 50%, rgba(157,243,196,1) 100%);*/
}
因为它是一个 90deg
方向使两个背景都 fixed
所以他们都将屏幕作为参考:
header {
font-size: 1.5rem;
text-transform: uppercase;
color: white;
margin-top: 30px;
margin-left: 40px;
}
.bg {
position: absolute;
top: 0;
left: 0;
z-index: -1;
background: linear-gradient(90deg, rgba(31, 171, 137, 1) 50%, rgba(157, 243, 196, 1) 0) fixed;
height: 52rem;
width: 100%;
}
h1 {
font-size: 5rem;
font-weight: 700;
text-align:center;
color: #0000;
background: linear-gradient(90deg, #fff 50%, blue 0) fixed;
background-clip: text;
-webkit-background-clip: text;
}
<div class="bg"></div>
<header>Plants</header>
<h1>Fresh Plants <br> for You.</h1>