在更大的图像上的小图像

时间:2016-04-06 17:40:08

标签: javascript jquery html css

我试图让小灰框位于页面黑框前面的左上方。在图像顶部的图像。我希望在黑匣子的顶部可以看到灰色框。我将顶部和左侧设置为零,我尝试使用z-index将灰色图像移动到黑色方块上方,但没有。它需要与IE9兼容:

https://jsfiddle.net/Lance_Bitner/zrjttnu1/

.nav-toggle {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
text-decoration: none;
text-indent: -999px;
position: relative;
overflow: hidden;
width: 70px;
height: 55px;
float: left;
display: block;
margin: 0 -2em 1em 0;


 }
.nav-toggle:before {
color: #444; /* Edit this to change the icon color */
font-family: "responsivenav";
font-style: normal;
font-weight: normal;
font-variant: normal;
font-size: 28px;
text-transform: none;
position: absolute;
content: url(img/menu2.gif);
text-indent: 0;
text-align: center;
line-height: 65px;
speak: none;
width: 100%;
top: 0;
left: 0;
}
.nav-toggle.active:before {
font-size: 24px;
content: url(img/menu3.gif);
}

1 个答案:

答案 0 :(得分:1)

您可以将导航切换框置于绝对位置并设置为顶部:0;

.nav-toggle {
    ...
    position: absolute;
    top: 0;
}

https://jsfiddle.net/Lpyumsck/1/