views:

277

answers:

3

So, it's official: I hate Internet Explorer. Yes, all bloody versions of it. :-D

So, I didn't think I was doing anything complicated here, but apparently I am. I have a bunch of list items in an unordered list styled for a navigation menu, and in Firefox, Chrome, Safari, and Opera, things work fine. What is supposed to happen is when you hover a navigational item, it should animate some growth and animate a background color change.

Nothing happens in Internet Explorer 7/8.

I think it's just tied to the animate function, since if I swap .animate with .css, it works.

http://project-cypher.net/wtf/ (*url removed - problem solved)

Ideas?

A: 

If I change the 'padding' : '6px 12px ' to 'padding' : '12px' it seems to work. Can you try this and report if it doesn't work on your end?

It's not perfect but it does something, and gets you a little closer to fixing it.

EDIT: Dang, wonder why not. Worked here. IE8. IDK, maybe you've got the solution from the other answer.

drachenstern
Hrm, that doesn't seem to work in IE8. Didn't test in 7... :)
Cypher
Yeah, not sure, but that's two people who say what they can get things to work in IE8 that I cannot. Maybe I need a reboot... just need to wait for this app to finish processing a few tables of data first...
Cypher
+1  A: 

Change your animation properties a bit using backgroundColor, paddingTop and paddingBottom, this should work:

$('ul.navigation li a').css('padding','0px 12px');
$('ul.navigation li a').hover(function() {
  $(this).stop().animate({
      backgroundColor : '#336699',
      'padding-top': 6,
      'padding-bottom': 6
    }, 150 );
}, function() {
  $(this).stop().animate({
      backgroundColor: '#660000',
      paddingTop: 0,
      paddingBottom: 0
    }, 150 );
});

This CSS:

ul.navigation li a {
    padding: 6px 12px;
    color: #fff;
    text-decoration: none;
    background: #600;
}
Nick Craver
Thanks, that gets me closer. The background color now fades in and out as it should. The padding is still not applying though... I've tried as you've written it, also tried encapsulating the value in single quotes... so far nothing.
Cypher
Cypher - Only in IE8? I tested, working here in IE8...
Nick Craver
@Nick - Yes, no dice in IE7/8, good in other browsers. I'm using jQuery 1.4.2. Can't remember the version of the color plugin that overrides .animate(), but I did download that a few days ago. Maybe I'll try grabbing a fresh, un-minified copy...
Cypher
This is the version of the color animations plugin I'm using:http://plugins.jquery.com/files/jquery.color.js.txtStill no go. I wonder what's different between what you have working and what I have that isn't working...
Cypher
@Cypher - I was wrong on my end, doesn't work on this computer with IE8....updated the answer with something that does, lack of padding allocated on page load seems to make it unable to animate, allocating then removing allows it. Take a look here for a demo: http://jsfiddle.net/py57F/
Nick Craver
Yeah, that certainly did the trick! I'm just glad IE supports conditional comments... thanks for the help Nick!
Cypher
A: 

I ran into this problem myself, the other day. I couldn't figure out why IE didn't properly animate the objects.

The answer is simple, though: use jQuery UI

jQuery UI includes an improved color plugin that actually works.

Check out the other neat things in jQuery UI while you're at it - buttons, dialogs, progress bars, tabs, etc.

George Edison
Nice plug. Really had nothing to do with it, but thanks anyway.
Cypher
It does. jQuery UI has a color plugin that allows backgroundColor to be used in `animate`.
George Edison
If you read the entire post, you'll see that wasn't the problem.
Cypher