CSS-继承祖父母Div的颜色的透明文本
我正在制作个人网站。我想添加一些有趣的东西,让人们写信给我的“墙”。这个想法是要有一个是线性梯度的祖父母div,是黑色的父级,与祖父母div匹配的文字(梯度的一部分将在文本下。我知道我可以给文本相同 但理想地像文本一样,看起来像是黑色div中的一个孔。
渐变为背景, https://i.sstatic.net/0ixos.png” alt =“ note text”>
到目前为止,这是我的CSS
.black {
overflow: hidden;
height: 88vh;
width: 98vw;
display: flex;
justify-content: center;
align-items: center;
background-color: #000000;
/* border-width: 2vh;
border-style: solid;
border-image: var(--gradient) 1; */
}
.gradient {
overflow: hidden;
height: 92vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
background-image: var(--gradient);
}
.wallText {
font-weight: 800;
font-size: 4vh;
justify-content: space-between;
color: transparent;
}
:
return (
<div className='grad'>
<div className="black">
<p className="wallText">WALL</p>
</div>
</div>
)
=“ nofollow noreferrer”>
I'm making a personal website. I wanted to add something fun and let people write to my 'wall'. The idea is to have a grandparent div that is a linear gradient, a parent div that is black and text that matches the grandparent div (the part of the gradient that would be under the text. I know I can just give the text the same gradient as the background but id ideally like the text to look as if it is a hole in the black div. Here is the page without text:
Here is my CSS so far:
.black {
overflow: hidden;
height: 88vh;
width: 98vw;
display: flex;
justify-content: center;
align-items: center;
background-color: #000000;
/* border-width: 2vh;
border-style: solid;
border-image: var(--gradient) 1; */
}
.gradient {
overflow: hidden;
height: 92vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
background-image: var(--gradient);
}
.wallText {
font-weight: 800;
font-size: 4vh;
justify-content: space-between;
color: transparent;
}
and the JSX:
return (
<div className='grad'>
<div className="black">
<p className="wallText">WALL</p>
</div>
</div>
)
Thanks in advance for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看CSS-tricks中的淘汰文字的帖子
在下面使用它是类似于您的片段。
check out the post for Knockout text from css-tricks
using that below is a snippet similar to yours.