Page is a not externally linkable
- Code, Content, and Presentation
-- CSS
---- DIV overlay staying static when I need it to move


swa66 - 6:11 pm on Dec 4, 2008 (gmt 0)


Using absolute positioning to center:


#image-overlay {
top: 50%;
margin-top: -29px; /* half of the height */
left: 50%
margin-left: -274px; /* half of the width */
}

Basically it first move e.g. the left side to the middle (left: 50%;) and then moves it back for half of the width of the element (negative margin).

If you want to center it relative to a parent, make sure the parent has position. Position can be given by e.g. "position: relative;" without needing to "nudge" it itself using left/top/right/bottom.


Thread source:: http://www.webmasterworld.com/css/3799931.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com