Google map as fixed background like on foursquare

2019-07-02 07:57发布

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条回答
做个烂人
2楼-- · 2019-07-02 08:29

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;
}
查看更多
登录 后发表回答