Wednesday, March 5, 2008

Mimic hovering in IE

This is old, but might help someone:
The CSS code

td:hover {
background-color: navy;
}

won't work in IE, since it only allows hovering for anchored elements.

A simple workaround for this is creating a new css class that mimics the hovering

td:hover, td.hover {
background-color: navy;
}

and adding in the HTML

<td onmouseover="this.className = 'hover'" onmouseout="this.className = ''">

This will do the trick in IE. A better but more complicated way is using IE's CSS behaviour features.

No comments: