RSS Forums RSS
Please support our HTML and CSS advertiser: Lunarpages Web Hosting

Hover Image Position ???

Join Date: Dec 2004
Posts: 1,592
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 35
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Hover Image Position ???

  #2  
Apr 28th, 2006
The problem is related to absolute vs. relative positioning. "Absolute" doesn't really mean "absolute", it means, "relative to the nearest parent element which is absolutely-positioned, but disregarding that parent element's content". A mouthful, I know.

What's happening is... equally hard to explain. An experiment helps.

 #leftMenu ul li img
{
position:absolute;
top:340px;
left:20px;
height:100px;
width:100px;
}

Change the position to "relative". You can see that your image is PART OF the "li" element. It's position will be influenced by it. Technically, the li is relatively-positioned, so the img should still be absolute relative to the body, but this is a LIST, and so obeys its own box model (it's like its own private page, in a sense). Saying it another way, the LI element is seen as the parent of the image, acting as if the LI was absolutely positioned, even though it isn't. So, the image's "top" will always be relative to the LI's position. Said a third way: the natural order of the the elements of a list will always supercede and/or influence CSS positioning.

Your choices:

Take the images out of the MENU. Have a separate DIV, and use Javascript to position the proper image within that DIV.

-or-

Don't use a LIST for your menu. That will make your pop-outs much more difficult.

I attempt to explain CSS positioning in this article. When you read the part about Absolute Position, just keep in mind that your LI element will act as if it is absolute.
Last edited by tgreer : Apr 28th, 2006 at 1:09 pm.
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:29 pm.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC