Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Full-Width Google Map And CSS

Tags:

css

maps

I have a full-width google map on a page using height="100%" and width="100%". I want to know put some css div stuff on top of it. I read that using negative values such as margin-top: -500px; will work, and they do, however when I try to assign a color to the background of the div, it doesn't display it over the map, it displays it under it, which isn't what I want at all. Is there a solution to this? Code:

<iframe width="100%" height="100%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?hl=en&amp;ie=UTF8&amp;ll=37.0625,-95.677068&amp;spn=56.506174,79.013672&amp;t=m&amp;z=4&amp;output=embed"></iframe>

<div class="content"> I want this text to be in a div box that has a black background. <br /> </div>

Style:

.content {
     margin-top: -500px;
     width: 390px;
     background-color: black;
}
like image 243
Joshua Terrill Avatar asked Apr 20 '12 17:04

Joshua Terrill


People also ask

How do you make a full width in CSS?

The width property is used to fill a div remaining horizontal space using CSS. By setting the width to 100% it takes the whole width available of its parent. Example 1: This example use width property to fill the horizontal space. It set width to 100% to fill it completely.

How do I change the CSS on Google Maps?

In the Google Cloud Console, go to the Map Styles page. Select the style you want, and click Customize Style.


2 Answers

html, body {
    width: 100%;
    height: 100%;
}

.map-frame {
    width: 100%;
    height: 100%;
    position: relative;
}

.map-content {
    z-index: 10;
    position: absolute;
    top: 50px;
    left: 50px;
    width: 390px;
    background-color: black;
    color: #FFF;
}

http://jsfiddle.net/oswaldoacauan/tx67C/

like image 174
Oswaldo Acauan Avatar answered Oct 13 '22 01:10

Oswaldo Acauan


add this to your css. works in chrome at least

position:absolute;
z-index:9999;
color:#fff;
like image 29
daniel.auener Avatar answered Oct 13 '22 02:10

daniel.auener