PDA

View Full Version : keep object centered, How?



jfitz
08 Apr 2006, 08:28 PM
i need to keep an iframe centered (in middle of screen) even when the page scrolls up or down. pls be as specific as posible, i am new to web development. thanx much. jim fitz

Wickham
09 Apr 2006, 01:09 AM
Three methods are available but you will have to abandon the iFrame unless you put it in a div according to the coding below. Anything fixed will mean other content will scroll behind it and be hidden.

Coding most of the page as position: relative with floats but the centre part as position: absolute and stated px for left and top will usually make it stay in one place while the rest scrolls.

Position: fixed is the best solution but IE6 does not support this. IE7 and Firefox do.

See also
http://tagsoup.com/-dev/null-/css/fixed/ (scroll and watch the left image)
http://www.exclipy.com/css/imageoverlay/ (image overlay which stays in fixed position - works in Firefox but I can't see the effect in IE).