INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How do you change the background image of a div on hover over a text link within that div?

How do you change the background image of a div on hover over a text link within that div?

How do you change the background image of a div on hover over a text link within that div?

(OP)
I'm trying to change a DIV's background image when I hover over a text link that is on top of that background image. I will have several links over that background image and each one will display a different background image when the mouse hovers over it and then it returns back to the original image when the mouse moves off the link. I'm beginning to think I can't solve this in CSS and I've avoided JavaScript so far because I'm not familiar with it. The code below provides a sample set up but the background image partially appears as background to the text link not the div. Although that is obviously wrong I don't know how to correct it in CSS.

Any help gratefully received.

CODE --> HTML

[<html>
	<head>
		<title>Test</title>
		<link rel="stylesheet" type="text/css" href="test.css">
	</head>
	<body>
		<div class="sitemap">
			<div class="home">
				<a href="#">Home</a>
			</div>
			<div class="links">
				<a href="#">Links</a>
			</div>
		</div>
	</body>
</html> 

And the CSS...

CODE --> CSS

@charset "utf-8";
/* CSS Document */

.sitemap{
	background-image:url(Images/sitemap_bg.jpg);
	background-repeat:no-repeat;
	background-position:top center;
	height:355px;
}

.home{
	position: absolute;
	margin:119px 0px 0px 232px;
}

.home a:hover{
	background-image:url(Images/home_map.gif);
}

.links{
	position: absolute;
	margin:175px 0px 0px 77px;
}

.links a:hover{
	background-image:url(Images/links_map.gif);
} 

Cheers

Brother Arnold

"keep passing the open windows..."

RE: How do you change the background image of a div on hover over a text link within that div?

Hi

Quote (Chris Coyier)

Let's be clear here, just in case someone is finding this from a search engine: there are no parent selectors in CSS, not even in CSS3.
( Parent Selectors in CSS )

Seems it will be solvable with CSS4 selectors, but for now you will need JavaScript.

Feherke.
feherke.github.io

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close