Jump to content

div background image


Fed

Recommended Posts

hi guysI am trying to put an image as background of a <div> through my cssit hasn't to be repeated and this is the code of the page:

<div id="menu">dddddddd</div>

and this is the css section:

#menu {  width: 980px;  height: 24px;  background-image:url("images/img_03.gif") !important;  text-align: left; }

I have tried both with "" and without, with ./ in front and whatsoever might come to a standard minded guyI have looked for samples and they show nothing different from what I am doingI have tried both in Firefox and IEno image is shown :|someone knows what I am missing?

Link to comment
Share on other sites

Worked ok for me when i used the W3C image as a test, are you sure you got the path to the image correct and did you put the #menu within the <style> and <head>?code with no-repeat

<head><style>#menu{ width: 980px; height: 24px; background: no-repeat url(http://w3schools.invisionzone.com/style_images/w3sbanner.gif) !important; text-align: left;}</style></head><body><div id="menu">dddddddd</div></body>

Link to comment
Share on other sites

Remember that if you use a relative path, it is treated as relative to the location of the stylesheet.The safest way might be to put your background images either in the same directory as your style sheet, or in a directory inside that directory.If the browser is unable to find the image based on the url, then no image is shown.

Link to comment
Share on other sites

Remember that if you use a relative path, it is treated as relative to the location of the stylesheet.The safest way might be to put your background images either in the same directory as your style sheet, or in a directory inside that directory.If the browser is unable to find the image based on the url, then no image is shown.

this was the issue :|I had set the image path like it was in the page folder and not in the /css/ forlderI didn't know it looked for it starting from th css file locationthanks a lot for your help :)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...