tags:

views:

94

answers:

3

this seems very simple and im puzzled as to why its not working...I want to change the background image of a DIV when rolling over it. It works on chrome and FF on a mac - but then not FF, IE on PC

CSS - /media/css/mystandard.css

div.flipper {background-color: #FFFFFF;}
div.flipper:hover {background-color: #F8FBFE;}

HTML

<HTML> <HEAD> <link rel="stylesheet" href="/media/css/mystandard.css"/></HEAD><BODY>        
<div class="flipper" >  
hello stack overflow!               
</div>
</BODY></HTML>

re:Catfish

Thanks for the tip. Unfortunately I can't use the tags because I plan on having the background color of a full DIV change (sort of like twitter.com Tweets view on rollover) and dont want to make all the text in the div a link

+1  A: 

Not all browsers support the :hover pseudo attribute on anything except an anchor tag <a>. You'll have to change you're html to

<HTML><BODY> <HEAD> import CSS here </HEAD>     
<div class="flipper" >
<a href="#">  
hello stack overflow!
</a>               
</div>
</BODY></HTML>

and youre css to

div.flipper a{background-color: #FFFFFF;}
div.flipper a:hover {background-color: #F8FBFE;}
Catfish
thanks, see above, i cant use the <a> tags =(
JiminyCricket
+1  A: 

If you have to use a <div>, you'll need to use javascript to do the hover. I suggest using jQuery for simplicity:

$("div.flipper").hover(
  function() { $(this).addClass("hover"); },
  function() { $(this).removeClass("hover"); }
);

Then change your CSS to:

div.flipper {background-color: #FFFFFF;}
div.hover   {background-color: #F8FBFE;}
cam
where do i put the jquery function?
JiminyCricket
nevermind figured it out thanks!http://stackoverflow.com/questions/275891/jquery-hover-and-class-selector
JiminyCricket
hmm its stil not working on a pc...
JiminyCricket
do you have a link to the page in question?
cam
unfortunately not, its behind a firewall. i fixed the show hide issue but now there is a problem with IE where the rollover doesnt always work. see my new post http://stackoverflow.com/questions/3550259/hover-in-ie-not-working-when-hovering-over-full-div
JiminyCricket
A: 

your problem is with your link for css. You have <link rel="stylesheet" href="/media/css/mystandard.css"/>

the first slice before media creates the problem. Use this <link rel="stylesheet" href="media/css/mystandard.css"/>

Sotiris