地图与导航栏重叠

时间:2016-04-18 06:53:27

标签: html css html5 css3

我将导航设置为固定,这样当我滚动时,它会粘在顶部。 但是当我滚动地图时,它会重叠到导航中 这是我使用的代码:

CSS:



#container header{
    background-color:white;
    width: 890px;
    padding: 0 0.8em;
    height: 120px;
    margin: auto;
    position: fixed;
}

#map{
    z-index:2px;
    position: relative;
    border-radius: 10px;
    border: 5px solid #eee;
    width: 26%;
    float:left;
    margin-top:50px;
}




这就是发生的事情

this is what happened

1 个答案:

答案 0 :(得分:1)

只需在你的CSS中做出改变: 从px移除z-index。 z-index创建平面,而不是px。

#map{
    z-index:2;
    position: relative;
    border-radius: 10px;
    border: 5px solid #eee;
    width: 26%;
    float:left;
    margin-top:50px;
}

如果您希望地图不会通过导航栏,请将地图的z-index设置为低于导航栏的z-index。