473,790 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CSS Hover Problem in IE

Hello,

I'm having a problem with the css hover effect in IE. I have an <a>
tag with the following CSS:

a.subNavItem {
display:block;
color:#464645;
padding:2px 7px 4px 6px;
font-family:verdana, arial,helvetica ,sans-serif;
font-size:9px;
font-weight:bold;
text-decoration:none ;
width:inherit;
border-bottom:1px solid #C8CBC7;
white-space:nowrap;
}

The width of the <atag inherits from its parent div so that the
border and hover effect will span across the entire div.

Here's the hover css:

a.subNavItem:ho ver
{
color:#00A5E5;
text-decoration:none ;
background-color:#F5F8F4;
}

Here is the HTML:

<div style="width:40 0px">
<a href="dir" class="subNavIt em">click</a>
</div>

THE PROBLEM:

In IE, the hover effect only works when I mouse over the text itself.
So even though the <atag is 400px wide, the hover only works if you
mouse over "click". In Firefox, I can mouse over anywhere inside the
<atag that spans across the width of the div, and my hover changes
work fine. I don't want to change all of my <atags to <div>.

Does anyone know a solution to this?

Oct 6 '06
24 5452
Els
boclair wrote:
fehays wrote:
>The code below solved it, but I'm not
sure why or if it's a good idea. For some reason, adding an empty
<spandisplay ed as a block that floats left fixes the hover without
having to set the <awidth. Seems to work in Firefox and IE.
[snip code with "superfluou s" span to make it work]
Try that without the span.
Without the span the lot looks the same, but the hover will not extend
to the entire width of the gray blocks in IE.

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Oct 11 '06 #21
Els wrote:
boclair wrote:
>fehays wrote:
>>The code below solved it, but I'm not
sure why or if it's a good idea. For some reason, adding an empty
<spandisplaye d as a block that floats left fixes the hover without
having to set the <awidth. Seems to work in Firefox and IE.

[snip code with "superfluou s" span to make it work]
>Try that without the span.

Without the span the lot looks the same, but the hover will not extend
to the entire width of the gray blocks in IE.
Odd. See http://www.boclair.com/test/css_hover.html or have I misunderstood

Louise

Oct 11 '06 #22
Els
boclair wrote:
Els wrote:
>boclair wrote:
>>fehays wrote:

The code below solved it, but I'm not
sure why or if it's a good idea. For some reason, adding an empty
<spandisplay ed as a block that floats left fixes the hover without
having to set the <awidth. Seems to work in Firefox and IE.

[snip code with "superfluou s" span to make it work]
>>Try that without the span.

Without the span the lot looks the same, but the hover will not extend
to the entire width of the gray blocks in IE.

Odd. See http://www.boclair.com/test/css_hover.html or have I misunderstood
If you look carefuly while hovering, you'll notice that only the top
couple of pixels of each block (besides the text in them) are
clickable. The larger part isn't. (tested in IE5, but I think the same
will be true for IE6)

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Oct 11 '06 #23
Els wrote:
boclair wrote:
>Els wrote:
>>boclair wrote:

fehays wrote:

The code below solved it, but I'm not
sure why or if it's a good idea. For some reason, adding an empty
<spandispla yed as a block that floats left fixes the hover without
having to set the <awidth. Seems to work in Firefox and IE.
[snip code with "superfluou s" span to make it work]

Try that without the span.
Without the span the lot looks the same, but the hover will not extend
to the entire width of the gray blocks in IE.
Odd. See http://www.boclair.com/test/css_hover.html or have I misunderstood

If you look carefuly while hovering, you'll notice that only the top
couple of pixels of each block (besides the text in them) are
clickable. The larger part isn't. (tested in IE5, but I think the same
will be true for IE6)
I see your point. To make this behaviour more obvious I added the
a:hover selector and border rules.

It seems though, in IE6 at least, adding the top rule to the absolutely
positioned containing div corrects the hover behaviour. (Adding a left
rule without the top rule does not.)

Now see http://www.boclair.com/test/css_hover.html

Louise
Oct 11 '06 #24
Els
boclair wrote:
Els wrote:
>boclair wrote:
>>Els wrote:
boclair wrote:

fehays wrote:
>
>The code below solved it, but I'm not
>sure why or if it's a good idea. For some reason, adding an empty
><spandispl ayed as a block that floats left fixes the hover without
>having to set the <awidth. Seems to work in Firefox and IE.
[snip code with "superfluou s" span to make it work]

Try that without the span.
Without the span the lot looks the same, but the hover will not extend
to the entire width of the gray blocks in IE.
Odd. See http://www.boclair.com/test/css_hover.html or have I misunderstood

If you look carefuly while hovering, you'll notice that only the top
couple of pixels of each block (besides the text in them) are
clickable. The larger part isn't. (tested in IE5, but I think the same
will be true for IE6)

I see your point. To make this behaviour more obvious I added the
a:hover selector and border rules.

It seems though, in IE6 at least, adding the top rule to the absolutely
positioned containing div corrects the hover behaviour. (Adding a left
rule without the top rule does not.)

Now see http://www.boclair.com/test/css_hover.html
Yup - agreed. "top:0;" makes all the difference.
Pretty weird, isn't it? :-)

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Oct 12 '06 #25

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3403
by: LRW | last post by:
Below I'll paste my CSS and the HTML in question. But what's happening is, I'm trying to establish a link behavior for a class that's separate from the normal link class. I've established a: 's with no underline and then an underline for hover...but oddly, only ONE link will actually show the underline on hover. All the rest, even with the same HTML, won't pop up an underline. I just don't get it! If I could get any advice I'd really...
6
17496
by: Nikolaos Giannopoulos | last post by:
If I have simplified html (I have removed height, weight, alt, etc... attributes to simplify the example) such as: <div id="header"> <a href="blah.html"><img src="img/blah.jpg"></a> </div> and the following CSS rule to apply a background color to text links on hover:
12
5019
by: Sander Tekelenburg | last post by:
Trying to make some images disappear on hover (works), and others appear on hover (works not). In tested browsers, this gives the expected result: IMG.disappear {visibility: visible} IMG.disappear:hover {visibility: hidden} this does not: IMG.appear {visibility: hidden} IMG.appear:hover {visibility: visible}
6
4943
by: Michael Rozdoba | last post by:
I've had some trouble getting IE to behave in respect of applying absolute positioning to a span on an a:hover. I can get it to work, but I don't understand why certain code causes it to fail to display the repositioned block. See an example at http://www.digitalrat.co.uk/test2/index.html Can anyone explain what IE thinks it's doing? The page is ugly as I've ripped most of the content & styling out to
8
12801
by: JLahm | last post by:
I have defined a class for my images called .image that specifies the default border color, width and style. I'd like to be able to have the pseudo elements link, visited and active have one color and style, while the hover class has a different color and style. I have the entries: a:link .image { border-color: #151515; border-style: solid; border-width: 2px; }
15
2829
by: Robert Mark Bram | last post by:
Hi All! Problem I began with: Netscape/Opera supports hover for different elements, IE only supports hover for <a> and I want to use hover for <td class="menu"> I then found a fix using some Javascript here: http://webpages.charter.net/mmmbeer/code/arbitrary-hover/ It works ok for IE now.
2
4174
by: skipc | last post by:
I posted a recent message regarding navigating a table using arrow keys. I've got the code for the navigation working. My table contains rows of links (anchors). I can get to a specific link using the code for capturing a key. However, once I get to the link, I can focus(), for example... but what I really want is to activate the "hover" styles. I can fake the hover effect using javascript, but how do I do this and still allow the...
7
17278
by: Cate Archer | last post by:
I want to have a border around an image that changes color when the mouse hovers over it. The following code works perfectly in FireFox but not in Internet Exploiter. The text link changes color but the image link stays the same. Anybody know how I can make it work in IE? I saw a web site where the guy got it to work in both browsers. <html> <head> <title>TEST</title>
4
2266
by: Sigilaea | last post by:
My previous post got squashed because m post is too long. Sorry for that: I have an AJAX page with a CSS menu at the top. My problem is the hover functionality stops working after someone clicks on one of the details in the main blue section. This only occurs in IE6. IE7 and FF work correctly. The URL to the page is: http://www.coralap.com/dies281css.aspx Steps to reproduce: 1. Mouse over the top menu and verify the hover works. 2....
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.