Image in background?
Moderator: General Moderators
Image in background?
I've got an image I want as the background image in my table, and this is the scrip I'm using:
<img src="background2.jpg" style="z-index: -1">
But when I go on the site, its not in the back. Its just a normal image. What am I doing wrong?
<img src="background2.jpg" style="z-index: -1">
But when I go on the site, its not in the back. Its just a normal image. What am I doing wrong?
If you want to place the image as a background-image for a specific element, use css:
Code: Select all
html:
<div id="maincolumn">This div element has a background img</div>
css:
#maincolumn {
background: url(images/somebackgroundimage.gif) no-repeat top left;
}- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Of course you can add the stylerules directly to an element. I don't know about an image. But it sounds kind of silly to me
Code: Select all
<div id="maincontent" style="color:#555;background:#111;" >
</div>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Have a read: http://www.w3schools.com/css/css_background.asp
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
That would make all of my tables look like that. i only want one to. How can my style only apply to one thing?feyd wrote:Have a read: http://www.w3schools.com/css/css_background.asp
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Use an ID attribute or a class attribute. I strongly suggest you read up on CSSm0u53m4t wrote:That would make all of my tables look like that. i only want one to. How can my style only apply to one thing?feyd wrote:Have a read: http://www.w3schools.com/css/css_background.asp
It doesn't seem to work for me... I've got <link href="/web-content/style.css" rel="stylesheet" type="text/css"> written in, and the file content is
.background { z-index: -1 }
background { z-index: -1 }
#background { z-index: -1 }
Just to be sure, and my img tag is <img src="background2.jpg" border="0" class="background"> But its not in the background. Any ideas?
.background { z-index: -1 }
background { z-index: -1 }
#background { z-index: -1 }
Just to be sure, and my img tag is <img src="background2.jpg" border="0" class="background"> But its not in the background. Any ideas?