好的,所以我尝试将Google Maps用作网站的背景。但是,当我尝试使用此代码在其上放置文本时:
.content{
z-index:0;
background-color:fffff;
position: absolute; top: 0; left: 0;
width: 900;
height: auto;
margin-right: auto;
margin-left: auto;
}
这给我地图带来了一个错误,它在地图上显示了它,这是我想要的,但是由于某种原因它不能与边距配合使用。我所有的代码都在这里:http://pastebin.com/uz6wwtYZ
谁能帮我,因为我希望网页和地图中心的内容成为背景。
谢谢。
最佳答案
当项目设置为绝对位置时,尝试调整顶部和左侧而不是边距:
.content{
z-index: 100;
background-color:fffff;
position: absolute; top: 100px; left: 100px;
width: 900;
height: auto;
margin-right: auto;
margin-left: auto;
}
希望有帮助吗?如我上面所做的那样,可能还需要设置更高的z-index值。
如果您希望它以自动边距值水平居中,但又要绝对定位,那么我认为您不能这样做。
您可以尝试通过为内容提供绝对宽度并偏移left属性来尝试这样做:
.content{
width: 500px;
z-index: 100;
background-color:fffff;
position: absolute; top: 100px; left: 50%;
height: auto;
margin: auto;
margin-left: -250px; /* half the value of the width */
}
这是使用您的代码的JS小提琴的链接:http://jsfiddle.net/4FLKt/1/似乎工作正常。
米奇
关于php - 使用Google map 作为背景?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13804006/