Link to home
Create AccountLog in
Avatar of mmalik15

asked on

using image map in a div with the background image

I know this question has been asked in the past but strangely could not find solution to the issue. My div is using a background image and I want to use image map on that image. Whats are the best options using either css, html, jquery, c# .
Avatar of IanTh
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of mmalik15


thanks for the comment. I know how to use imagemap but what i m asking is how to use imagemap when the image is set as a background image in a div

<div id="bgContainerFade" style="background-image:url(/media/55921/0048mp_murraypark_hp_image_bg.jpg);"></div>
The two ways of using the image are mutually exclusive.  A background can never be clickable, let alone have links applied as a map.

You either have to make the image content or change your design.  If you need something overlaid in the image then use absolute positioning and z-index; but that will interfere with the clickability of the image.

If you don't have any overlays for the image, you could use a transparent image as the map, overlaid in the image and that might simulate what you are trying to do.

thanks for the comments.

i have tried adding a hyperlink with the absolute position. But this hyper link for some reason is  not working.

see the code

<a href="" class="mainHolderLink1">&nbsp;</a> inside the div with id="bgContainer"
<a href="" class="mainHolderLink1">" " </a>

does that work?
Avatar of COBOLdinosaur
Flag of Canada image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of StealthyDev

Give the below code a try...

Also, you can store the left, top, width, height properties in an array of your programming languages - javascript/.net, whatever..

.outerDIV {
	background-repeat: no-repeat;
	width: 270px;
	height: 50px;

#e {
	position: absolute;
	top: 23px;
	height: 15px;
	width: 13px;
	left: 9px;

#x {
	position: absolute;
	top: 23px;
	height: 15px;
	width: 13px;
	left: 25px;

#p {
	position: absolute;
	top: 23px;
	height: 15px;
	width: 13px;
	left: 38px;

	function showAlert(div) {

<div id="bgContainerFade" class="outerDIV">
	<div id="e" onclick="javascript: showAlert(this);"></div>
	<div id="x" onclick="javascript: showAlert(this);"></div>
	<div id="p" onclick="javascript: showAlert(this);"></div
	<div id="e2"></div>
	<div id="r"></div>
	<div id="t"></div>
	<div id="s"></div>
	<div id="e3"></div>
	<div id="x2"></div>
	<div id="c"></div>
	<div id="h"></div>
	<div id="a"></div>
	<div id="n"></div>
	<div id="g"></div>
	<div id="e4"></div>

Open in new window

thanks for all the comments.

I have added 'img' inside the div as suggested and removed the background image coming via css. You may look at it again on

The problem now I have is z-index. If I set the z-index of bgcontainer div to 10 or so. The image map works but i can't click any other hyperlinks on the page.
Only one thing can be on top, and you can only click on the top layer.  Maybe you are starting to understand why most developers would not consider going back to image maps which most of us quit using 10 years ago.