Dudsmack
11-21-2003, 10:28 AM
Is there a property to set a background image for a DIV? I know there use to be but it seams to have been discontinued by the w3c.
|
Click to See Complete Forum and Search --> : Background image inside a div Dudsmack 11-21-2003, 10:28 AM Is there a property to set a background image for a DIV? I know there use to be but it seams to have been discontinued by the w3c. fredmv 11-21-2003, 11:21 AM It can be done like this: <a href="#" onclick="document.getElementById('foo').style.backgroundImage='url(http://www.neitherday.com/textureheaven/BlueMood/BlueMood.jpg);';">Set background image.</a> <div id="foo" style="height: 120px;"></div> NOTE: Make sure to get the full URL since the URL is shortened. Jish 11-21-2003, 04:44 PM Try this: <style type="text/css"> div#myBackground { background-image: url("myBackgroundImage.jpg"); width: 100px; height: 100px; } </style> </head> <body> <div id="myBackground">&bnsp;</div> fredmv 11-21-2003, 06:39 PM You shouldn't use quotes around the URL to the image or external CSS file as it doesn't work in some browsers. Also, I believe Dudsmack was referring to changing the background image of an element through scripting since it's in the DHTML section. Just some friendly advice, welcome to the forums. :D webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |