Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Full div hover 1

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
Is it possible to hover the full width of a div, rather than the width of just the text, in a div which contains a text hyperlink.
I cannot use javascript and would prefer not to rely on hacks.

Thanks

Keith
 
Hi

[tt]div:hover[/tt] does what you want and works in standard compliant browsers. ( So not in Explorer 6 and older. )

If you want Explorer 6 compatibility, you can set [tt]a { display: block; }[/tt] then the [tt]a:hover[/tt] instead of [tt]div[/tt].

Feherke.
 
You can also use JS
Code:
onmouseover="this.style.className='hoverclass';"
onmouseout="this.style.className='';"

The onmouse changes the class property for the layer. The onmouseout removes the change thus setting it back to whatever you have set it by default.

Notice that you will need to create a style set with the desired properties; this is the style set you will use in lieu of 'hoverclass' as shown on the code above.

Hope this helps!


--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
The onmouseout removes the change thus setting it back to whatever you have set it by default.

It's worth noting that it blanks the class out, not sets it back to whatever it was before.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
I stand corrected :)

I thought that if you had set

<div class="someclass" ...> ... </div>

and then use an onmouseout trigger as above, the layer will simply revert back to class="someclass". I guess this has worked for me because inheritance behavior.

Thanks for the heads up on that!


--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
Thanks, the display:block command works a treat.

It was originally set up using Javascript but some of our screen reader users have complained about the navigation so it had to be done again.



Keith
 
Hi

Keith said:
It was originally set up using Javascript but some of our screen reader users have complained about the navigation so it had to be done again.
[surprise] That is interesting. The presence of such JavaScript code should not harm in any condition. I would say, the problem must be caused by another piece of code.

Feherke.
 
Not really sure what the cause was but I cured it by removing the Javascript. then links with only a few letters were awkward to click for some of the partially sited users who prefer to use a mouse.
They keep you on your toes!
You should hear what they say about Vista - Well actually, I couldn't print it here.

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top