Google map as fixed background like on foursquare

2019-07-02 07:34发布

问题:

I'm trying to do something like this. I want to have google map as a fixed background and place my content(some text) on it as it's made on foursquare. Also i want to be able to scroll my content. This is my effort:

#map
{
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    z-index: 0;
}
#content
{
    width: 200px;
    margin: auto;
    position: relative;
    z-index: 1;
    border: 4px solid black;
}
​

But the map disappears. Any help will be appreciated.

回答1:

Here's a way you can do it: http://jsfiddle.net/X5r8r/927/

html, body {
    height:100%;
}

#map-container {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
}

#map
{
    width: 100%;
    height: 100%;
}
#content
{
    width: 200px;
    position: absolute;
    z-index: 1;
    top:0;
    left:0;
    border: 4px solid black;
    background:#fff;
    padding:20px;
}