我有两个div(一个在背部,另一个是关于它的字体)。背景Div显示Google地图,并精确填充屏幕(宽度= 100%,高度= 100%)。 但前景DIV,它的高度要大得多。如何保持背景DIV出现desptie滚动垂直
如何允许与保持谷歌地图它的位置固定,尽管垂直滚动前台DIV垂直滚动?
正如你看到的。背景图像是固定的,尽管垂直
我有两个div(一个在背部,另一个是关于它的字体)。背景Div显示Google地图,并精确填充屏幕(宽度= 100%,高度= 100%)。 但前景DIV,它的高度要大得多。如何保持背景DIV出现desptie滚动垂直
如何允许与保持谷歌地图它的位置固定,尽管垂直滚动前台DIV垂直滚动?
正如你看到的。背景图像是固定的,尽管垂直
仅仅包裹在一个固定的容器中的图。
<head>
<style type="text/css">
#map-wrapper,#maps{ width:100%; height:100%; }
#map-wrapper{ position:fixed; }
#article{
position:absolute; width:50%; height:200%;
margin:0 0 20px -25%;
background:#000 url(http://placekitten.com/1500/1000) center center no-repeat;
text-align:center; overflow:hidden;
}
</style>
</head>
<body>
<div id="map-wrapper">
<div id="maps"></div>
</div>
<div id="article"></div>
</body>
在Mac OSX上测试最新版本的Chrome,FF,Opera和Safari。
在这里找到了答案: http://groups.google.com/group/google-maps-api/browse_thread/thread/33a3ed4d8cb6ba04?pli=1
但是被放大地图的问题,出来的时候,用户将鼠标悬停在“背景”仍然存在。
祝你好运! :)
我希望下面的CSS可以帮助你:
body {
background-image: url('smiley.gif');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
使用固定的定位
例如
HTML:
<div id="fg">
this is the foreground
</div>
<div id="bg">
123 ... this is the background
</div>
CSS:
div#fg{
position: absolute;
top: 0px;
z-index: 1;
height: 1000px;
left: 25%;
width: 50%;
color: white;
border: green 5px solid;
}
div#bg{
position: fixed;
top: 0px;
left: 0px;
z-index: 0;
width: 100%;
height: 100%;
background: url('http://img2.socwall.com/Nature/General/200717041506-1877.jpg') no-repeat blue;
}
我希望这有助于
您不必定义像素高度或宽度,我只是用它作为一个例子。
我更新的例子,包括背景图像 – zehelvion