[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Align absolute div the same in Firefox and IE

Posted on 2006-06-29
1
Medium Priority
?
946 Views
Last Modified: 2008-02-01
Hi
I have a vertical menu on my site (i.e. top to bottom) that uses table rows for each menu element.
When a user mouses over each menu item, I have a submenu appear as a DIV (initially this div is hidden).
To stop the submenu div breaking the page flow, I made it absolute, so it floats over everything. But because my site is centred, I never know the exact position of the menu, so I have used the trick of putting the absolute div inside a relative div:

<tr>
<td width="158" height="24" align="center" onmouseover="javascript:document.getElementById('submenu1').style.display = 'block';" onmouseout="javascript:document.getElementById('submenu1').style.display = 'none';" valign="middle">
<div style="position: relative;">
<a href="http://foo">Main menu link</a>
<div id="submenu1" style="display: none; position: absolute; top: 0px; left: 140px;">Submenu HTML here</div>
</div>
</td>
</tr>

This works fine except the submenu div is positioned differently in IE and Firefox...

Is there a way to do this that will make the submenu div appear in the same place in both IE and Firefox? I am pregenerating the menu html and saving it in a database, otherwise I could have done a browser detect and changed the top amd left attributes of the absolute div for each browser.

cheers
0
Comment
Question by:pr0fess0r
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
GoofyDawg earned 1000 total points
ID: 17032654
You could use the !important directive to make FF and other compliant browsers work:

display: none; position: absolute; top:4px!important;top: 0px; left:150px!important;left: 140px;

IE ignores any CSS attributes that have an !important attached, while FF and other more compliant browsers will obey the directive and use those values. There is one caveat... IE7 (beta) will obey the important directive, but it still renders like IE 6, which sucks... Hopefully they'll have that fixed by the time it goes gold.

GoofyDawg
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a how to build your own CSS3 slideshow and when I say CSS3 I mean just CSS with no javascript in sight! There a few examples online of how to do this but most just show you an example without any explanation, others make it more complicat…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question