我有以下设计,其中我有一个介于两者之间的图像<div>
。我的目标是保持两个 div 之间的图像。
在此示例中,我希望主图像 (400x200) 位于绿色图像 ( #firstLayer
) 和灰色 (身体背景) 之间。我的解决方案在 Firefox 16、safari 和 Chrome 中运行良好,但在 IE 中不起作用。在 IE 中,图像显示在#firstLayer
.
这是问题的JFiddle
这是用于快速查看的 html 和 css:
HTML:
<body>
<div id="firstLayer">
<img id="image" class="center" src="http://lorempixel.com/400/200/" >
<div id="mainContent">
main page content
</div>
</div>
</body>
CSS:
body{
background:gray;
}
#firstLayer{
background: url("http://www.enough.de/fileadmin/docimport/images/background-image.png") no-repeat;
height:500px;
width:500px;
}
img#image{
z-index:-1;
}
.center{
width: 400px;
height: 200px;
position: absolute;
left: 50%;
top: 50%;
margin-left: -200px;
margin-top: -100px;
}
IE中这个问题的修复方法是什么?