cant get bg to display in any browser

  You are currently not logged in. You can view the forums, but cannot post messages. Log In | Register

07-Jan-12 17:44
hi i read these 2 articles

http://www.elated.com/articles/html-images/
http://www.elated.com/articles/controlling-background-images-and-colours/

my question is.. can you have the background img in a subfolder to the style sheet? cause your 2 posts above don't mention in.. they do say you can have an image in a sub directory.. but is this also applicable for background images, or do background images need to be in the same stylesheet.css folder

heres how i have it..
[root]/style/images/bg.jpg


and this is my code
CSS

body {
margin: 0px;
padding: 0px;
color: #aeaeae;
font-family: Tahoma, Geneva, sans-serif;
font-size: 13px;
line-height: 1.5em;
background-color: #26163d;
background-image: url(/images/bg.jpg);
background-repeat: repeat-x;
background-position: top;
text-align:center;
}



HTML

<body>
<h1>this is supposed to display the bg</h1>
</body>



it doesn't work in any browser
tried IE, firefox and chome,

any help would be much appreciated
many thanks everyone

ps: IE does seem to pull up the assigned bg colour (PURPLE)
but in the other browsers, its just plain white?? really confused

[Edited by stifler on 07-Jan-12 17:48]
11-Jan-12 17:42
@stifler: URLs used in a style sheet are relative to the style sheet, not the HTML document.

Assuming your style sheet is in your /style folder then you want to use:


background-image: url(images/bg.jpg);


--
Matt Doyle, Elated
3rd Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/

 
New posts
Old posts

Follow Elated