| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
CSS hover
Hi,
I was wondering if there is way of changing the color or background-image of one element when hovering over any other element. Something that I know is possible with javascript, but I want to know if this can be done using pure CSS. Example: If i have 5 links in a horizontal row and I would like different images to appear below them in another <div> tag when I hover over them. is this possible? do u have an example? thanks a lot, Oren |
|
#2
|
||||
|
||||
|
You're gonna hafta use a bit of javascript to call the CSS I think... like this:
CSS: Code:
<style type='text/css'>
.no1 {
background-color:#ffffff;
}
.no2 {
background-color:#ff9933; /*orange*/
}
</style>
HTML: Code:
<div onmouseover="document.getElementById('area').className='no2';" onmouseout="document.getElementById('area').className='no1';">
text
</div>
<br />
<div id='area' class='no1'>
Text 2
</div>
I tested it - should work fine. Is this what you had in mind? Or would you like me to expand? |
|
#3
|
|||
|
|||
|
Quote:
Got it, thanx! |
|
#4
|
||||
|
||||
|
you can add hover sub-class for any element in html but it won't work for IE browser, for now... hopefully they would support it in IE7 though.
|
|
#5
|
||||
|
||||
|
No JS needed, though like Shadow said, it doesn't work in IE.
![]() Code:
.item {
background-color: #000;
}
.item:hover {
background-color: #FFF;
}
|
|
#6
|
||||
|
||||
|
BBD & Shadow - the question was about changing the background of an unrelated element from the one being hovered over
![]()
__________________
-
thought-after | my thoughts on web development Get Firefox, the developers browser Budget hosting - recommended [/left] |
|
#7
|
||||
|
||||
|
Quote:
lol good catch... so hover is misleading word in this case. ![]() |
|
#8
|
||||
|
||||
|
Haha, whoops...good eye lafinboy
![]() |
|
#9
|
||||
|
||||
|
Probably should have been described as a mouseover event rather than a hover. But now we're getting back into semantics
![]() |
|
#10
|
||||
|
||||
|
I would assume Shadow Wizard could easily achieve this with JavaScript. :P
|
|
#11
|
||||
|
||||
|
Quote:
medianox did this in post #2, I couldn't give any better code. ![]() |
![]() |
| Viewing: ASP Free Forums > Web Design > Web Layout > CSS hover |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|