66

I have a div that displays a Google map.

How do I make another div float over the map div?

user664833
  • 18,397
  • 19
  • 91
  • 140
Adham
  • 63,550
  • 98
  • 229
  • 344
  • 1
    possible duplicate of [div on top of div with Google Maps API](http://stackoverflow.com/questions/2786967/div-on-top-of-div-with-google-maps-api) – Pekka May 17 '11 at 22:06

4 Answers4

149

Try this:

<style>
   #wrapper { position: relative; }
   #over_map { position: absolute; top: 10px; left: 10px; z-index: 99; }
</style>

<div id="wrapper">
   <div id="google_map">

   </div>

   <div id="over_map">

   </div>
</div>
Dan
  • 3,338
  • 5
  • 36
  • 58
15
#floating-panel {
  position: absolute;
  top: 10px;
  left: 25%;
  z-index: 5;
  background-color: #fff;
  padding: 5px;
  border: 1px solid #999;
  text-align: center;
  font-family: 'Roboto','sans-serif';
  line-height: 30px;
  padding-left: 10px;
}

Just need to move the map below this box. Work to me.

From Google

Matheus
  • 151
  • 1
  • 2
4

Just set the position of the div and you may have to set the z-index.

ex.

div#map-div {
    position: absolute;
    left: 10px;
    top: 10px;
}
div#cover-div {
    position:absolute;
    left:10px;
    top: 10px;
    z-index:3;
}
Adrian Rodriguez
  • 3,232
  • 2
  • 24
  • 34
-12

absolute positioning is evil... this solution doesn't take into account window size. If you resize the browser window, your div will be out of place!

atnmachine
  • 37
  • 2
  • 15
    You are talking about fixed positioning, not absolute. – P Varga Mar 22 '12 at 14:49
  • 3
    Not if you use it correctly, you need to make sure your absolute positioned element is inside a relative positioned element, otherwise your absolutely positioned elements is positioned in relation to the viewport size. – abrosis Mar 05 '15 at 14:17