vertically align absolutely positioned div elements

  • Thread starter Guybrush Threepwood
  • Start date
M

Mitja Trampus

Guybrush said:
On http://users.skynet.be/am036990/test.html 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?

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
</div>

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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top