有没有办法使用文本作为CSS的背景? [英] Is there a way to use use text as the background with CSS?

查看:100
本文介绍了有没有办法使用文本作为CSS的背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用动态文字作为标签中某些元素的背景。因此,我可以使用图像(动态文本)。

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:

<div id="container">
    <div id="background">
    Text to have as background
    </div>
    Normal contents
</div>

然后CSS:

#container {
   position: relative;
}

#background {
   position: absolute;
   top: 0;
   left: 0;
   bottom: 0;
   right: 0;
   z-index: -1;
   overflow: hidden;
}

这里是它的一个例子

这篇关于有没有办法使用文本作为CSS的背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆