Nie Selam Nie Selam - 3 months ago 23
CSS Question

Google map div area covering contact form

I am trying to put a form on top of a google map. The map is displayed correctly but it covers the form. here is the fiddle. It is neat form with nothing inside.

.map-wrapper {
position:relative;
height:500px;
z-index:0;
}
.map-canvas {
background-color:#00FFFF; /*FOR TRIAL ONLY*/
width:100%;
z-index:2;
color: #29383F;
position:absolute;
height:100%;
left:0;
top:0;
right:0;
clear:both;

}


#ff {z-index:50000;} /*not originally part of my code but tried anyway. failed */

#ff input.short{display:block;width:50%;border-radius:4px;-webkit-border-radius:4px;-moz-border-radius:4px;color:#000; border:1px solid #AFAFAF;padding:12px;margin: 5px 0 10px 0;font-size: 16px;max-height: 45px;}


#ff .sendButton {cursor:pointer;background-color: transparent;width:15%;color:#333;border: 3px solid #333;color: #333;font-size: 20px;padding: 8px 0 10px;}


and my html simply:

<div class="map-wrapper">
<div class="map-canvas" id="map-canvas">Loading map...</div>
<form id="ff" name="ff" action="#" class="contact-form" method="post" accept-charset="utf-8">
<input type="text" name="from" id="from" class="short" placeholder="Your Name" required="required" autofocus="autofocus" value="" /><br/><br/>

<input type="email" name="fromemail" id="fromemail" class="short" placeholder="Your Email" required="required" value="" /><br/><br/>

<input class="sendButton send-mailbtn" type="submit" name="submit" id="submit" value="Submit"><br/><br/>

</form>

</div>


I have tried opacity on the canvas but as expected, it affects visiblity of the map.

Any clues please?

Answer

I made this possible simply by setting the z-index of the .map-canvas div to -1, as opposed to 2.

JSFiddle

Right now you're telling the page to place the div above the form, which you don't want to happen.

Another option, which I haven't yet tried but I know will work, and avoids giving z-index a negative value, is to place the form within a div, set its position as absolute and give it a z-index higher than that of the map div.

EDIT:

I have tested the 2nd option and here is the result:

JSFiddle

Comments