Hi,
Can anyone advise how to change the background colour of a complete DIV upon mouseover.
Is there a term for it?
| SitePoint Sponsor |



Hi,
Can anyone advise how to change the background colour of a complete DIV upon mouseover.
Is there a term for it?



Since you're learning I would google 'hover tutorials'. It's the hover mode that change on mouse over. I think that would be enough. I will check...
I just checked these Keywords: css hover tutorial.
There is a complete list of people who have already explained things.
Best Regards



Brilliant thanks, how do I a class to the DIV?





Hi,
This is the HTML and CSS I have but I cant get it to work, am I doing it correctly?
<div id="aboutuslinksheader">
<div id="feature">
About
</div>
</div>
#aboutuslinkscell {
float:left;
width:25%;
padding-left: 1%;
border:1px solid #CBCBCB;
}
#feature:hover {
background: #7B7B7B;
}


Yes, that should work nicely. Something else on your page must be getting in the way. (You aren't testing this in IE6, I presume? The hover effect only works on links in that dead browser.)
Can you post a link to your page?
Edit:
I should clarify that the hover effect should work here. But the float: left etc. can't work as they are for a div with a different id from that of the outer div in your HTML.



Hi,
I got it working thanks however I have padding inside the aboutuslinks DIV for the content but the padding doesn't change colour. Is there anyway of making the padding area change colour also?
#aboutuslinks {
float:left;
width:96%;
font-family:helvetica, geneva, serif;
font-size:1.2em;
border:1px solid #CBCBCB;
color: #7B7B7B;
padding-top: 3px;
padding-bottom: 3px;
padding-left: 3%;
}
#feature:hover {
background: #7B7B7B;
}





Hi,
I merged the two together but all the padding and font styling only comes into affect when I mouseover the DIV.
I set out two DIVs so only the background would change on Mouseover. But the padding on the DIV surrounding feature doesn't change colour.



This is what I have, whatever change I make it doesn't have the desired affect of making everything in aboutuslinks change colour including the padding.
<div id="aboutuslinks">
<div id="feature">
Links One
</div>
</div>
#aboutuslinks {
float:left;
width:96%;
font-family:helvetica, geneva, serif;
font-size:1.2em;
border:1px solid #CBCBCB;
color: #7B7B7B;
padding-top: 3px;
padding-bottom: 3px;
padding-left: 3%;
}
#feature:hover {
background: #F4F5FF;
}
It can't because the #feature is inside of #aboutus, meaning #feature can only occupy the space that is left and the padding belongs to the outer element, not the inner element.
So, instead you'd need to apply the padding to the inner element:
Code:#aboutuslinks { float:left; width:96%; font-family:helvetica, geneva, serif; font-size:1.2em; border:1px solid #CBCBCB; color: #7B7B7B; } #feature { padding-top: 3px; padding-bottom: 3px; padding-left: 3%; } #feature:hover { background: #F4F5FF; }



I see, cheers dude.
Bookmarks