Reputation: 550
is this possible? My CSS isn't bad, but I can't cannot wrap my hear around this. I want to use a background image behind a header, but I want the header to "knock out" the background image leaving the background either side. I hope that makes sense.
I've made a fiddle incase anyone wants to have a bash...Thanks!
Upvotes: 0
Views: 499
Reputation: 17061
The easiest way of doing this is with border-image
. See your updated fiddle here.
Here's the CSS for it (multiple browsers):
.container {
border-width: 20px;
-moz-border-image: url(http://fc09.deviantart.net/fs71/f/2010/163/2/d/PixelBackground_02_by_Kara1984.jpg) 27 round;
-webkit-border-image: url(http://fc09.deviantart.net/fs71/f/2010/163/2/d/PixelBackground_02_by_Kara1984.jpg) 27 round;
border-image: url(http://fc09.deviantart.net/fs71/f/2010/163/2/d/PixelBackground_02_by_Kara1984.jpg) 27 round;
text-align:center;
}
I generated this code with Border-Image.com (because writing this yourself is confusing as all hell :P).
Upvotes: 4
Reputation: 14398
I've update your jsFiddle:
Now you got transparent background on h1.
I've use rgba color model: Red (range: 0-255) Green (0-255) Blue (0-255) Alfa (0-1). If you want 50% transparency use 0.5 alfa there.
This works in all common browsers (most IE will need filter / hack for it)
Upvotes: 0
Reputation: 71384
Well it is transparent now. It sounds like what you want is to apply a background color matching some other color (body background color?) to the h1. Something like this:
Obviously using whatever background color you want and adding margin/padding etc. to give you the proper "knock-out" size.
Upvotes: 0