473,779 Members | 2,038 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 #1
24 5450

fehays wrote:
I'm having a problem with the css hover effect in IE.
a { width: 100%; }

Oct 6 '06 #2


On Oct 6, 4:35 pm, "Andy Dingley" <ding...@codesm iths.comwrote:
fehays wrote:
I'm having a problem with the css hover effect in IE.a { width: 100%; }
Andy,

You're right, that would work with the code I posted, however, I tried
to simplify my actuall code and in doing so, I made a mistake.

The HTML looks like this:
<div>
<a href="dir" class="subNavIt em">click</a>
</div>

So the parent <divdoes not have a width set. This is because I want
the div to just expand with the text.

So, with your solution, if I add 100% width to the <ait stretches out
beyond the parent <div>

Any ideas?

Thanks.

Oct 6 '06 #3
Els
fehays wrote:
On Oct 6, 4:35 pm, "Andy Dingley" <ding...@codesm iths.comwrote:
>fehays wrote:
>>I'm having a problem with the css hover effect in IE.a { width: 100%; }

Andy,

You're right, that would work with the code I posted, however, I tried
to simplify my actuall code and in doing so, I made a mistake.

The HTML looks like this:
<div>
<a href="dir" class="subNavIt em">click</a>
</div>

So the parent <divdoes not have a width set. This is because I want
the div to just expand with the text.

So, with your solution, if I add 100% width to the <ait stretches out
beyond the parent <div>
No it doesn't, the parent div is also 100% of its parent.
Instead of width, you can use height too. If you're sure the link text
won't wrap, you can set a height of 1.2em for example.
But you'll still need to set a limit on the width if you don't want it
to take up the full available width inside its parent.

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/

Now playing: Various - Nebukadnezar
Oct 6 '06 #4
On 2006-10-06, fehays <fe****@gmail.c omwrote:
[snip]
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?
The <ais display: block and width: auto, so it should automatically
fill all its available width. Which I'm guessing it is doing for some
purposes (or you'd have mentioned the background colour not extending to
the full width).

So sounds like the IE bug is in the way they implement hover. Maybe it
has something to with <a>s. There's no way to tell except experimenting
with random permutations of the content.

Knowing this doesn't help much, except that the strategy changes.
Oct 7 '06 #5
Els
Ben C wrote:
So sounds like the IE bug is in the way they implement hover. Maybe
it has something to with <a>s. There's no way to tell except
experimenting with random permutations of the content.
Some things are well documented. Hover extending to full width of the
<aelement in IE is one of them. It just needs a set width or height.

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/

Now playing: Elly & Rikkert - Kauwgomballenbo om
Oct 7 '06 #6
Els wrote:
>
Some things are well documented. Hover extending to full width of the
<aelement in IE is one of them. It just needs a set width or height.
or zoom:1

--
Berg
Oct 7 '06 #7


On Oct 7, 1:48 am, Ben C <spams...@spam. eggswrote:
On 2006-10-06, fehays <feh...@gmail.c omwrote:
[snip]
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?The <ais display: block and width: auto, so it should automatically
fill all its available width. Which I'm guessing it is doing for some
purposes (or you'd have mentioned the background colour not extending to
the full width).

So sounds like the IE bug is in the way they implement hover. Maybe it
has something to with <a>s. There's no way to tell except experimenting
with random permutations of the content.

Knowing this doesn't help much, except that the strategy changes.
Ben,

Yes, you are correct. The background color, border, etc are all
filling out the width fine. It is ONLY the hover that is not working
as desired in IE.

Sounds like as Els said, I need to have the width or height set.
Problem is, the text is dynamic so I can't set a height or width. I
may just have to live with the hover behavior in IE unless there is
another way.

-FH

Oct 9 '06 #8
Els
fehays wrote:
On Oct 7, 1:48 am, Ben C <spams...@spam. eggswrote:
>On 2006-10-06, fehays <feh...@gmail.c omwrote:
[snip]
>>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?The <ais display: block and width: auto, so it should automatically
fill all its available width. Which I'm guessing it is doing for some
purposes (or you'd have mentioned the background colour not extending to
the full width).

So sounds like the IE bug is in the way they implement hover. Maybe it
has something to with <a>s. There's no way to tell except experimenting
with random permutations of the content.

Knowing this doesn't help much, except that the strategy changes.

Ben,

Yes, you are correct. The background color, border, etc are all
filling out the width fine. It is ONLY the hover that is not working
as desired in IE.

Sounds like as Els said, I need to have the width or height set.
Problem is, the text is dynamic so I can't set a height or width. I
may just have to live with the hover behavior in IE unless there is
another way.
I don't get it. If the text width is dynamic, how do you define the
width of the <aelement at all, even before hovering? Full width?
That's 100%. As Bergamot says in his reply in this thread, zoom:1 is
also an option. It will still fill out the <aelement for the same
width as width:100% does though.

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

Els wrote:
fehays wrote:
On Oct 7, 1:48 am, Ben C <spams...@spam. eggswrote:
On 2006-10-06, fehays <feh...@gmail.c omwrote:
[snip]

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?The <ais display: block and width: auto, so it should automatically
fill all its available width. Which I'm guessing it is doing for some
purposes (or you'd have mentioned the background colour not extending to
the full width).

So sounds like the IE bug is in the way they implement hover. Maybe it
has something to with <a>s. There's no way to tell except experimenting
with random permutations of the content.

Knowing this doesn't help much, except that the strategy changes.
Ben,

Yes, you are correct. The background color, border, etc are all
filling out the width fine. It is ONLY the hover that is not working
as desired in IE.

Sounds like as Els said, I need to have the width or height set.
Problem is, the text is dynamic so I can't set a height or width. I
may just have to live with the hover behavior in IE unless there is
another way.

I don't get it. If the text width is dynamic, how do you define the
width of the <aelement at all, even before hovering? Full width?
That's 100%. As Bergamot says in his reply in this thread, zoom:1 is
also an option. It will still fill out the <aelement for the same
width as width:100% does though.

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Well yes I do want full width. 100%. But, if I set the <ato 100%, it
stretches the <divthat it is contained in. I'm assuming this is also
because the div does not have a width set? But again, I cannot set the
width of the <diveither because of the dynamic text. Maybe i'm doing
something else wrong??

Oct 9 '06 #10

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

Similar topics

7
3402
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
5018
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
4942
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
17276
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
2264
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
9636
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
9474
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
10306
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...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5373
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
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
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
3632
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.