Reputation: 945
Im trying to make a div change when I hover on another div. I have done this a million times before but for some reason I just can not see why this one isnt working.
CSS
#floatimg:hover > #float_tools
{
opacity: 1;
}
#float_tools
{
width: 150px;
margin: auto;
opacity: 0.3;
}
HTML
<div id='floatBox'>
<div id='float_image'>
<img id="floatimg" src="">
</div>
<div id='float_tools'>
<div id='float_prev'><a href='javascript:void' onclick=''><img src='images/Button_Prev.png' width='50px'></a></div>
<div id='float_close'><a href='javascript:void' onclick=''><img src='images/close.png' width='50px'></a></div>
<div id='float_next'><a href='javascript:void' onclick=''><img src='images/Button_Next.png' width='50px'></a></div>
</div>
</div>
Upvotes: 1
Views: 110
Reputation: 2337
It's simply because #float_tools
div is not a direct child of #floatimg
.
Try something like:
<div id='floatBox'>
<div id='float_image'>
<img id="floatimg" src="">
<div id='float_tools'>
<div id='float_prev'><a href='javascript:void' onclick=''><img src='images/Button_Prev.png' width='50px'></a></div>
<div id='float_close'><a href='javascript:void' onclick=''><img src='images/close.png' width='50px'></a></div>
<div id='float_next'><a href='javascript:void' onclick=''><img src='images/Button_Next.png' width='50px'></a></div>
</div>
</div>
</div>
CSS:
#float_image:hover > #float_tools
{
opacity: 1;
}
#float_tools
{
width: 150px;
margin: auto;
opacity: 0.3;
}
Upvotes: 1
Reputation: 3610
When you try to use the greater than sign (>
), the affected element should be a direct child of the hovered element. In your HTML, the hovered element and the affected element are not directly related to each other.
It would be better this way:
#float_image:hover + #float_tools
{
opacity: 1;
}
#float_tools
{
width: 150px;
margin: auto;
opacity: 0.3;
}
Upvotes: 0