好的,我已尝试将 Google map 作为我网站的背景。但是当我尝试使用这段代码在上面放置文本时:
.content{
z-index:0;
background-color:fffff;
position: absolute; top: 0; left: 0;
width: 900;
height: auto;
margin-right: auto;
margin-left: auto;
}
这给我一个错误,它显示在 map 的顶部,这是我想要的,但由于某种原因它不能使用边距。我所有的代码都在这里:http://pastebin.com/uz6wwtYZ
任何人都可以帮助我,因为我想要网页中心的内容和 map 作为背景。
谢谢。
最佳答案
尝试在元素设置为绝对位置时调整顶部和左侧而不是边距:
.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 值。
如果您希望它以自动边距值水平居中,但又绝对定位,我认为您做不到。
您可以通过为您的内容提供绝对宽度并偏移左侧属性来尝试此操作:
.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 Fiddle 的链接:http://jsfiddle.net/4FLKt/1/似乎工作正常。
米奇。
关于php - 使用谷歌地图作为背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13804006/