Forum Moderators: not2easy

Message Too Old, No Replies

Background images in a <div> element

         

Alfbede

9:34 am on Oct 28, 2005 (gmt 0)

10+ Year Member



I am trying to create a menu using the <div> element and want to put a background image in it but have so far been unsuccessful, and am now at the point where I have exhausted my knowledge and that of the book I have; HELP!

HTML:-

<body>
Menu test page...
<div id="box">
This is the menu.
</div>
</body>

CSS (external style sheet):-

#box
{
background-image: url("images/bckgnd.jpg");
position: relative; top: 75px; left: 90px; width: 220px; height: 346px;
border: ridge;
padding: 15pt;
}

Can anyone please tell me what I have got wrong?

benihana

10:02 am on Oct 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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

remove the quotes and check the path. Otherwise should be fine.

Alfbede

11:04 am on Oct 28, 2005 (gmt 0)

10+ Year Member



Have tried it with and without quotes and trhe path is correct but it still doesn't work. I rfigure I just have to resign myself to failure...

Alfbede

12:13 pm on Oct 28, 2005 (gmt 0)

10+ Year Member



To try and solve this problem I have just tried putting the CSS into the head of my webpage and it works OK, but still does not from an external style sheet...

If anyone does have a solution to my problem I would be eternally grateful.

tata668

12:18 pm on Oct 28, 2005 (gmt 0)

10+ Year Member



Remember that external stylesheets are easily cached. Try hitting shift-refresh or use the web developer toolbar on Firefox to easily disable your cache..

Maybe it will help?

Robin_reala

12:53 pm on Oct 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think paths in external files are relative to the external file itself, not the calling file. For example, if your CSS is in a subdirectory change 'images/bckgnd.jpg' to '../images/bckgnd.jpg'.

Alfbede

12:55 pm on Oct 28, 2005 (gmt 0)

10+ Year Member



Maybe it would help to know that I am using Rapid CSS 2004 in conjunction with IE 6 and no matter what I do this will not work from an external style sheet, and I pride myself on being very inventive...

SOB SOB SOB - tearing hair out in frustration...

Alfbede

12:59 pm on Oct 28, 2005 (gmt 0)

10+ Year Member



I think paths in external files are relative to the external file itself, not the calling file. For example, if your CSS is in a subdirectory change 'images/bckgnd.jpg' to '../images/bckgnd.jpg'.

Well don that man!

So damned simple that I couldn't see it for myself, the one thing that I took for granted.

Deep bows to a GENIUS!

Thanks all for the help - I will be back afore long...