This is my CSS
.test {
background-image:url('images/smiley.gif');
background-repeat:repeat;
}
This is my HTML:
<div class="test" id="xyz">some code which should come background to image</div>
The code that I have written sets a background image.
But I want to put an image on top of the text, instead of behind it, so that it covers the text. (I also want it to automatically repeat to fill the element, which could be any size.)
How can I do that?
Interesting task. I think this should do it, if you’re willing to put in an extra HTML element. (Alternatively, use
.test:beforeinstead of.test .foregroundImage, like in Georges’ answer).HTML
CSS
See http://jsfiddle.net/RUJYf/ for a working example.