Forum Moderators: not2easy

Message Too Old, No Replies

changing bg color of another tag

css hover change color div

         

DruManiac

4:32 pm on May 3, 2007 (gmt 0)

10+ Year Member



can i change the bgcolor of a small div inside a container div by hovering the container?

i want to change the bgcolor of the "list1topborder" div by hovering "list1" div...

such as:
<div id="list1">
<div id="list1top">
<div id="list1topborder">&nbsp;</div>
<div id="listtoptitle">
<a href="./int.htm" target="browse"><img id="listtitle" src="xtra/home.gif" /></a>
</div>
<div id="listmiddle"></div>
</div>
</div>

Fotiman

5:02 pm on May 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not for IE6 (IE6 does not support :hover on div elements). But this should work for IE7 and Firefox:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset:utf-8">
<title>Background Color :hover Example</title>
<style type="text/css">
#list1 { padding: 2em; background-color: #ccc; }
#list1topborder { background-color: red; }
#list1:hover #list1topborder { background-color: blue; }
</style>
</head>
<body>
<div id="list1">
<div id="list1top">
<div id="list1topborder">&nbsp;</div>
<div id="listtoptitle">
<a href="./int.htm" target="browse"><img id="listtitle" src="xtra/home.gif" /></a>
</div>
<div id="listmiddle"></div>
</div>
</div>
</body>
</html>

DruManiac

6:41 pm on May 3, 2007 (gmt 0)

10+ Year Member



thnx brother thats all i needed, ive got a JS for IE anyways..