你可以达到你想要的(可能无法在旧版浏览器的工作)什么:
#frame { ... no special css (but background should be [semi-]transparent) ... }
#frame img { position: relative; z-index: -1; }
注意负z-index
号。这就是为什么一些浏览器有问题,但所有现代浏览器都可以处理这个问题。这个测试用例可以在Firefox 3.6,IE8,Safari 4中运行(IE6 & 7需要没有包含元素的位置,也就是说,它必须是position: static
才能使其工作);
<div style="border: 5px solid red; width: 190px; height: 190px; position: relative; zoom: 1; margin: 20px">Example Text
<div style="position: absolute; z-index: -1; width: 200px; height: 200px; background-color: blue; opacity: .7; top: -10px;"></div>
</div>
它在我原来的CSS中,这只是缩小的示例代码。 – Benny 2010-07-27 05:56:02
你能告诉我们完整的代码吗?试试jsfiddle.com,如果你不想把它放在这里。 – hookedonwinter 2010-07-27 05:56:40
-1 - http://jsfiddle.net/dC76q/ – 2010-07-27 05:59:36