Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How do I create a transparent div over another div that contains google maps?

Posted on 2008-10-09
1
3,277 Views
Last Modified: 2012-05-05
I am creating a site that uses google maps and I am trying to put a transparent div over the map. The only way I could get it done was this:

<div id="container" class="container">&nbsp;
    <div id="map_canvas" class="map"></div>
    <div id="over_map" class="over_map" ></div>
</div>
   However it has a bug. If you open the page in a IE tab, then move the focus to another IE, wait a few seconds, and go back to the initial tab, it looses the transparent efect. I have created a small test file so yo can see it better.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
 
div.container {
	position:relative;
	width: 100%;
	height: 100%;
 
}
 
div.map {
	position:absolute;
	width: 100%;
	height: 100%;
	top:0;
	left:0;
	z-index:1;
	background-color: red;
	}
div.over_map {
	position:absolute;
	width: 100%;
	height: 100%;
	top:0;
	left:0;
	background-color: black;
	z-index:2;
	filter:alpha(opacity=50);
		-moz-opacity:0.5;
	opacity:0.5;
 
}
</style>
</head>
 
<body style="">
 
<table width="100%" height='100%' border="1" >
	<tr>
		<td width="20%"></td>
		<td width="80%">
			<div class="container">&nbsp;
				<div id="map_canvas" class="map">&nbsp;</div>
				<div id="over_map" class="over_map">&nbsp;</div>
			</div>
		</td>
	</tr>
</table>
</body>
</html>

Open in new window

0
Comment
Question by:ldeabreu
1 Comment
 

Accepted Solution

by:
ldeabreu earned 0 total points
ID: 22686345
I found my own solution to this. I decided not to use the CSS opacity. Now I am using a transparent background and it works fine.

Here is the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
 
div.container {
	position:relative;
	width: 100%;
	height: 100%;
 
}
 
div.map {
	position:absolute;
	width: 100%;
	height: 100%;
	top:0;
	left:0;
	z-index:1;
	background-color: red;
	}
div.over_map {
	position:absolute;
	width: 100%;
	height: 100%;
	top:0;
	left:0;
	background: url(../images/1x1pixel.gif) repeat;
	z-index:2;
}
</style>
</head>
 
<body style="">
 
<table width="100%" height='100%' border="1" >
	<tr>
		<td width="20%"></td>
		<td width="80%">
			<div class="container">&nbsp;
				<div id="map_canvas" class="map">&nbsp;</div>
				<div id="over_map" class="over_map">&nbsp;</div>
			</div>
		</td>
	</tr>
</table>
</body>
</html>

Open in new window

0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a how to build your own CSS3 slideshow and when I say CSS3 I mean just CSS with no javascript in sight! There a few examples online of how to do this but most just show you an example without any explanation, others make it more complicat…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question