views:

760

answers:

1

This is really strange. I've got this site where I have a list menu with a simple :hover effect on each item in the menu.

http://w3box.com/mat/

In Firefox it works just fine. But i IE7 atleast there's a lag. I haven't tested it in IE8 but my guess is that it's there as well.

Now, I've been trying out veriations to the code to see what might cause the issue. And I've seen alot of posts about similar scenarios. But none of them seemed to apply to my case.

So just now I noticed that in my css stylesheet, I've got this:

li:hover {
background-image: url(img/TopLine.png); 
Height:29px;

}

Strange enough, if I remove the height specifications, there is no lag! What could be causing this? Could it be layers of padding and margins to the parent li class? Or the parent class above that one?

This is the code of these items. The rest of the css you can under /main.css of the site

#header {
padding-right:7%;
height: 57px;
background-image:url(img/TopLine.png); }

.header a {
font-family:georgia;
font-size:22px;
color:#ebebeb;
text-decoration:none; }

.header li {
float:right;
list-style: none;
margin-top:10px;
padding-top:18px;   
padding-left: 23px;
padding-right: 23px;
height:23px; }

li:hover {
background-image: url(img/TopLine.png); 
Height:29px; }

Any ideas on how I can improve this?

A: 

I'm not really getting any lag. The first time there is a slight delay though - this is most likely because the background image is loading.

You'd be better off setting a background on the list item proper then changing the background position on hover. (There are plenty of questions on SO about this.)

DisgruntledGoat
That's odd @DisgruntledGoat, I am getting a noticeable lag in IE7 even on a quite powerful machine - it's in IEtester, though. Did you try with a "real" IE7?
Pekka
Not sure what you mean about setting a background on the list item? Could you elaborate? Would it mean not using :hover. Btw, I tried setting the :hover on both 'a:hover" and '.header:hover' etc and the lag happens anyway. It's very strange. But I don't know why it only seems to happen when I set it's height though. Perhaps I need to reposition the entire menu.
Kenny Bones
@Pekka: no I'm just using compatibility mode.
DisgruntledGoat
@Kenny: what I mean about the background is that if you set a background image on hover, the first time you hover it loads the image then, not beforehand, hence a delay. You can combine two backgrounds into one image then on hover change the position. Look up "CSS sprites" for more information.
DisgruntledGoat
@DigruntledGoat: But it's the same 1 pixel background image every time, isn't it? It shouldn't be loaded on every hover, should it? It has no "no-cache" headers or anything, I already checked that yesterday.
Pekka
I have changed alot of things now. I tried using FontFace instead, incorporating the font in a CSS file instead, which seems to work alot smoother! I've also added a lavalamp-menu effect as well, even though it's not positioned well enough yet. It seems alot smoother now anyway!
Kenny Bones
@Pekka: You're right, the lag would only be on the first hover, which seemed to be what I was experiencing. I didn't check the image, I assumed it included the text and everything but looks like custom fonts.
DisgruntledGoat