|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Change background of UL for each LI hover?
Hi All,
Anyone know of a way to change acheive this behaviour? I want to have several links in LI and when one hovers over the LI, the background of the whole UL changes (not just the background of the list item itself). Thanks in advance for any pointers. Cheers, :)Ben |
|
#2
|
|||
|
|||
|
Code:
ul:hover {
background-color: #fd9;
}
IE(4 through 6)/Win only support :hover on <a> elements. Three ways to simulate :hover in IE5-6/Win: Dean Edward's "IE7" patch for IE5-6 whatever:hover http://www.htmldog.com/articles/suckerfish/ |
|
#3
|
|||
|
|||
|
RE: Change background of UL for each LI hover?
Thanks for the reply, Kravvitz.
"UL:Hover" would change when one hovered over the UL, though, no? How would that vary it for each LI hover? :)Ben |
|
#4
|
|||
|
|||
|
You didn't say that you wanted to use a different color for each <li>.
![]() You would need to use JavaScript. It would be better to not use inline events, however, for the purposes of providing you with an example, I will use them here. Code:
<li onmouseover="if(this.parentNode) this.parentNode.style.backgroundColor='#fd9';" onmouseout="if(this.parentNode) this.parentNode.style.backgroundColor='';"></li> |
|
#5
|
||||
|
||||
|
If your CSS stylesheet predefined a background color, your mouseout will set it to null... do'nt forget to put an appropriate value in there if you want your UL to have a background when someone mouse is elsewhere on the page.
It's fairly obvious, but I had to point it out. ![]()
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter! DevArticles Forum Moderator "The net is a waste of time, and that's exactly what's right about it." -- William Gibson |
|
#6
|
|||
|
|||
|
RE: Change background of UL for each LI hover?
Yeah, was afraid I'd have to use JS. Was hoping there was a way to do it with just CSS, but oh well. Thanks for the responses.
Ben |
|
#7
|
||||
|
||||
|
CSS3 introduces some interesting pseudo-classes as far as :first-child, :last-child, or my favourite, :nth-child(even)... but alas, no sign of :parent... I can't help but think it would destroy the idea of "Cascading"
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Web Design > Advanced Web Development > Change background of UL for each LI hover? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|