Forum Moderators: not2easy

Message Too Old, No Replies

IE Rollover block element issue

         

zimmo

1:59 pm on May 22, 2009 (gmt 0)

10+ Year Member



I have a simple list rollover menu, and works fine in all browsers, but in ie the block element is not working as it should. When you rollover the links you have to have the mouse positioned over the text in the block to get it to show as a rollover, if you move to the right of the text (where in other browsers it still shows as a rollover) you lose the rollover effect. I have checked and checked and cannot see why this is happening in ie.

Here is my code for the navigation layer.


<div id="navigation" style="position:absolute; left:89px; top:303px; width:193px; height:307px; z-index:3; overflow:visible">
<p class="f-lp"><ul>
<li><a href="index.html">HOME</a></li>
<li><a href="events.html">EVENTS</a></li>
<li><a href="news.html">NEWS</a></li>
<li><a href="galleries.html">GALLERIES</a></li>
<li><a href="timeline.html">TIMELINE</a></li>
<li><a href="contact.html">CONTACT INFO</a></li>
</ul>
<p class="address f-lp">To234JA</p></p>
</div>

And here is my css code


/* navigation */
#navigation {
font-family: Tahoma;
font-size: 14px;
color : #ffffff;
border: 1px solid #fff;
border-width:0px 0px 1px 1px;
}
#navigation ul {
list-style: none;
margin: 0px;
padding: 0;
}

#navigation a {
display: block;
color: #FFFFFF;
width: 178px;
padding: 5px 5px 5px 10px;
border: 1px solid #fff;
border-width:0px 0px 1px 0px;
text-decoration: none;
}

#navigation a:hover {
color: #FFFFFF;
background-color: #000000;
padding: 5px 5px 5px 10px;
}
/* END OF Navigation */

daveginorge

3:41 pm on May 25, 2009 (gmt 0)

10+ Year Member



What height is the block element? try adding a line-height: equal to the block height. I find it cures the problem for me

SuzyUK

5:00 pm on May 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



an IE Bug, even in 7 it seems :(

it's because of the absolute positioning of the navigation div, and it's not a regular hasLayout bug that I can see, so if you can't position that div in another way, (are you source ordering?) then can you add a background color to the Navigation div - the same as the background color of the page will do, but "transparent" won't work so this will depend on if there are any background images.

If that's not an option and changing the positioning method is not an option then shout back or do tell a solution if you've found one

enigma1

10:45 am on May 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



what is the whole html and css you are using? When I try it here with IE6 and IE7 I do not see the problem. I moved the mouse cursor passed the link text and the rollover works.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<style type="text/css">
/* navigation */
#navigation {
font-family: Tahoma;
font-size: 14px;
color : #ffffff;
border: 1px solid #fff;
border-width:0px 0px 1px 1px;
}
#navigation ul {
list-style: none;
margin: 0px;
padding: 0;
}

#navigation a {
display: block;
color: #FFFFFF;
width: 178px;
padding: 5px 5px 5px 10px;
border: 1px solid #fff;
border-width:0px 0px 1px 0px;
text-decoration: none;
}

#navigation a:hover {
color: #00FFFF;
background-color: #FF0000;
padding: 5px 5px 5px 10px;
}
</style>
</head>
<body bgcolor="#000000">
<div id="navigation" style="position:absolute; left:89px; top:303px; width:193px; height:307px; z-index:3; overflow:visible">
<p><ul>
<li><a href="index.html">HOME</a></li>
<li><a href="events.html">EVENTS</a></li>
<li><a href="news.html">NEWS</a></li>
<li><a href="galleries.html">GALLERIES</a></li>
<li><a href="timeline.html">TIMELINE</a></li>
<li><a href="contact.html">CONTACT INFO</a></li>
</ul>
<p>To234JA</p></p>
</div>
</body>
</html>

SuzyUK

11:34 am on May 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



enigma, I found it was very sporadic in the tests, sometimes it worked sometimes it didn't I just kept rolling the mouse up and down the list..

Quirks Mode it does work in, and your code does indeed work, because your Doctype is triggering quirks mode, which I wouldn't really recommend because of the other IE back compat problems it causes

try you code replacing the first line with

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
you should see it then :(

zimmo

12:37 pm on May 26, 2009 (gmt 0)

10+ Year Member



Hi Suzy... my code already has what you put, did you mean something different. I have tried all sorts, but the really weird thing is that this code works on another site, albeit with extra sub navs, and the rollovers are fine. Just as you say sporadic when you test, totally puzzling as you would think it just would not work. Open to any ideas?

enigma1

1:02 pm on May 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Suzy, I changed the doctype to the way you suggested and saw the problem. So I believe he needs to place another div (like a container of absolute positioning) and then setup the navigation id with relative positioning. I moved the navigation style into the css section.

Here is the code that I changed and seems to be ok with IE6,IE7, FF, Opera, Safari.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<style type="text/css">
/* navigation */
#navigation {
font-family: Tahoma;
font-size: 14px;
color : #ffffff;
border: 1px solid #fff;
border-width:0px 0px 1px 1px;

position:relative;
margin: 303px 0px 0px 89px;
z-index:3;
overflow:visible;
height: 307px;
width:193px;
}
#navigation ul {
list-style: none;
margin: 0px;
padding: 0;
}

#navigation a {
display: block;
color: #FFFFFF;
width: 178px;
padding: 5px 5px 5px 10px;
border: 1px solid #fff;
border-width:0px 0px 1px 0px;
text-decoration: none;
}

#navigation a:hover {
color: #00FFFF;
background-color: #FF0000;
padding: 5px 5px 5px 10px;
}
</style>
</head>
<body bgcolor="#000000">
<div id="navigation">
<p><ul>
<li><a href="index.html">HOME</a></li>
<li><a href="events.html">EVENTS</a></li>
<li><a href="news.html">NEWS</a></li>
<li><a href="galleries.html">GALLERIES</a></li>
<li><a href="timeline.html">TIMELINE</a></li>
<li><a href="contact.html">CONTACT INFO</a></li>
</ul>
<p>To234JA</p></p>
</div>
</body>
</html>

swa66

1:37 pm on May 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



zimmo, enigma1:

you cannot nest <p>'s and a <ul> does not suit as a child of a <p> ...
please use valid code to start from.

enigma1

2:06 pm on May 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you talking about this?
<p><ul>
?
It was from the OP I just removed the class definition as it doesn't exist on his CSS code. (see top)

<p class="f-lp"><ul>

swa66

2:59 pm on May 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, yes : the browser will act as if there's a </p> in front of that <ul>.
And that means it'll also ignore one of the </p> further down. Better not rick the browser get confused and make the input valid, well structured (not so easy with a loose dtd I guess, but needed if you want to avoid nasty surprises.

Aside of that a <p> inside another </p> is also not allowed. Now the first one most likely will get closed by the browser already, still ... why take the risk.

enigma1

3:07 pm on May 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes sure I have already tested that way too, but it wasn't changing anything regarding the rollover problem. I just copied whatever the OP had and re-posted it with the changes.

SuzyUK

9:11 pm on May 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes enigma, it's a puzzling one.. I too validated the code Swa, but it made no difference

zimmo, yes the code I gave enigma was the one which showed your problem, I suggest you stick with this correct Doctype too despite this problem as to go with a "Quirks Mode" triggering one, although fixing this issue, will bring you many more.

I have a feeling that nesting divs would solve the problem, as enigma says so their suggestion might well work (I've not had a chance to look any more at it yet). I've have a very strong feeling that this is one of those IE things that only happens under a very precise set of circumstances so changing them will work and is possibly why your other sites are fine with their sub navs etc..

As I too suggested earlier if you don't have to use Absolute Positioning (AP) on that nav that should fix it, enigmas suggestion to AP a wrapper then put the nav inside it might just be one way to differentiate the circumstances?

The easiest "solution" I found was to add a background color to the nav div, are you not able to do that? images?

..and don't ask me why that works it just does! - IE problems are often related to background color changes on hover, but why it works here I don't know! :o)

SuzyUK

9:29 pm on May 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



@enigma, I've just tested your code too and yes it does work because you've removed the AP, sorry in my previous post I thought you had meant to add an extra wrapper in to change which element the AP was on - theory being changing the Parent/Child relationship.. (still looking at that theory)

Yes that code works too, but it may not be so easy for the OP to use relative positioning directly on the nav div, it depends where in the source code the nav is - remember Relative Positioning with co-ordinates only offsets the element, i.e. it still leaves a "space" where the original element would've appeared so if the nav is early in the source the rest of the following elements would need to either negatively margined or relatively positioned too in order to fill the "gap"

@zimmo, I think we need to know what the rest of your template is so we can see if there's "Source Ordering" involved, and/or if there's background images involved to try and nail down your best solution in this case..