Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Div change background color on hover?
Old 03-13-2009, 11:44 AM Div change background color on hover?
Ultra Talker

Posts: 316
Trades: 0
Hello

I would like a DIV which has a text link in to change background color when the mouse enters the DIV (not just when the text is hover over.

The entire DIV would become a link, not just the text.

Any ideas? I've google'd it but not sure what to look for.

Thanks
Joe3000 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-13-2009, 01:12 PM Re: Div change background color on hover?
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
Well, you can do it, but it won't work in IE6 or below because it doesn't support hover on anything except the <a> tag. In GOOD browsers, this would work:

Quote:
#box1{
width: 400px;
height: 200px;
background: pink;
margin: 0 auto;
}

#box1:hover{
background: lime;
}
To make IE work you need some Javascript - do a search for whatever:hover
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 03-13-2009, 01:45 PM Re: Div change background color on hover?
Ultra Talker

Posts: 316
Trades: 0
Thanks.

That is making the DIV background change color which is good.

But is it possible to make the whole DIV a link?
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 03-13-2009, 03:15 PM Re: Div change background color on hover?
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
So like this? It's not exactly making the div a link, but it's giving the fake impression....

Code:
.hover a {
padding: 10px;
text-decoration: none;
color: #000;
}
.hover a:hover {
padding: 10px;
background: lime;
}
HTML Code:
<div class="hover">
<a href="#">hover</a>
</div>
- Steve
__________________
if($stevej == "helpful") { $talkupation += $user_power; }
stevej is offline
Reply With Quote
View Public Profile
 
Old 03-13-2009, 03:53 PM Re: Div change background color on hover?
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
You cannot put a block-level div inside an inline element (the <a>), so no, you can't really make a div a link.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 03-13-2009, 05:12 PM Re: Div change background color on hover?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Make the <a> into a block element (display:block) give it 100% height and the anchor element will fill the div
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Div change background color on hover?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17046 seconds with 12 queries