vertically align absolutely positioned div elements

Discussion in 'HTML' started by Guybrush Threepwood, Dec 14, 2005.

  1. On I have 2 div elements
    underneath each other. But when I lower the font size (in Firefox: <ctrl>+-),
    the lowest box slides in front of the upper box. How can I avoid this?
    Guybrush Threepwood, Dec 14, 2005
    1. Advertisements

  2. No idea why it does what it does, but the fix is easy: don't
    use absolute positioning with #menu and #searchbox, but
    rather on a new containing div#foo:
    <div id="foo"> <-- absolutely postioned
    <div id="menu">...</div>
    <div id="searchbox>...</div> <-- add some margin-top

    This is even better than the original solution because it
    avoids the explicit top:18em on #searchbox, which would have
    to be changed every time you change the contents of #menu.
    Mitja Trampus, Dec 14, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.