将背景图片放在文字上? [英] Put background image over text?

查看:107
本文介绍了将背景图片放在文字上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不是关于如何在背景图像上放置文字的常见问题.

This is not the apparently-common question about how to put text over a background image.

我有一个背景图像,我想将其作为覆盖层使用-应该在文本上方.为简单起见,在现有div上放置另一个div并赋予背景图片要困难得多.

I have a background image that I want to work as an overlay -- it should be over the text. For simplicity sake, placing another div over the existing div and giving that the background image is much more difficult.

背景图片是否有可能位于文字上方?

Is it possible for a background image to be above the text?

推荐答案

这绝对是不可能的,理应如此.如果您可以将元素的 background 属性用于除 background 之外的任何内容,那将是错误的(并且令人困惑).

This is definitely not possible, and rightfully so. It would be wrong (and confusing) if you could use the background property of an element for anything other than the background.

执行此操作的正确方法是在容器内放置绝对位置的div(宽度和高度设置为100%),并加上以下文本: http://jsfiddle.net/EvqNb/

The right way to do this is with an absolutely positioned div (with width and height set to 100%) within the container, alongside the text: http://jsfiddle.net/EvqNb/

这篇关于将背景图片放在文字上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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