有没有办法通过 CSS 使用文本作为背景? [英] Is there a way to use use text as the background with CSS?
本文介绍了有没有办法通过 CSS 使用文本作为背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的标签中使用动态文本作为某些元素的背景.因此,我可以使用图像(动态文本).如何仅使用 CSS 或 JavaScript 来实现?
I would like to use dynamic text as background of certain elements in my tag. Because of this, I can use images (dynamic text). How do I do it with just CSS or JavaScript?
推荐答案
你可以在你的相对定位元素中拥有一个绝对定位元素:
You can have an absolutely positioned element inside of your relative positioned element:
#container {
position: relative;
}
#background {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: -1;
overflow: hidden;
}
<div id="container">
<div id="background">
Text to have as background
</div>
Normal contents
</div>
这是一个例子.
这篇关于有没有办法通过 CSS 使用文本作为背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文