How to float a div over Google Maps?

前端 未结 4 796
迷失自我
迷失自我 2020-12-02 06:08

I have a div that displays a Google map.

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

相关标签:
4条回答
  • 2020-12-02 06:30
    #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

    0 讨论(0)
  • 2020-12-02 06:35

    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>
    
    0 讨论(0)
  • 2020-12-02 06:41

    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!

    0 讨论(0)
  • 2020-12-02 06:44

    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;
    }
    
    0 讨论(0)
提交回复
热议问题