原理:
<相对层>
<最高层_绝对定位>
<中间层_绝对定位>
<最底层_提供宽高>
</相对层>
<!--浮动div,z-index:999解决除ie6的所有浏览器-->
<div id="ad" style="position:absolute; z-index:999">
<!--为绝对定位准备相对定位,float:left;脱离标准流,自适应宽高 overflow:hidden;隐藏超出的 -->
<div style="position:relative; overflow:hidden; display:block; float:left;">
<!--(最底层)在标准流中 提供宽高-->
<img src="1.jpg" border="0">
<!--(中间层)脱离标准流,绝对定位,拥有一个自动的宽高,不够的话,可以自己再设,_filter:alpha(opacity=0);去除iframe颜色,ie6 中 iframe层级永高于select -->
<iframe style=" position:absolute; top:0px; left:0px; border-style:none;z-index:1;opacity=0;_filter:alpha(opacity=0);"></iframe>
<!--(最高层)绝对定位,与中间层重合,设置层级高于iframe -->
<div style="position:absolute; top:0px; left:0px; z-index:2;">
<a href="#" target="_blank"><img src="1.jpg" border="0"></a>
</div>
</div>
</div>
zhangbest5个人原创,转载请注明,谢谢!
<相对层>
<最高层_绝对定位>
<中间层_绝对定位>
<最底层_提供宽高>
</相对层>
<!--浮动div,z-index:999解决除ie6的所有浏览器-->
<div id="ad" style="position:absolute; z-index:999">
<!--为绝对定位准备相对定位,float:left;脱离标准流,自适应宽高 overflow:hidden;隐藏超出的 -->
<div style="position:relative; overflow:hidden; display:block; float:left;">
<!--(最底层)在标准流中 提供宽高-->
<img src="1.jpg" border="0">
<!--(中间层)脱离标准流,绝对定位,拥有一个自动的宽高,不够的话,可以自己再设,_filter:alpha(opacity=0);去除iframe颜色,ie6 中 iframe层级永高于select -->
<iframe style=" position:absolute; top:0px; left:0px; border-style:none;z-index:1;opacity=0;_filter:alpha(opacity=0);"></iframe>
<!--(最高层)绝对定位,与中间层重合,设置层级高于iframe -->
<div style="position:absolute; top:0px; left:0px; z-index:2;">
<a href="#" target="_blank"><img src="1.jpg" border="0"></a>
</div>
</div>
</div>
zhangbest5个人原创,转载请注明,谢谢!
![](http://hiphotos.baidu.com/zhangbest5/pic/item/e294ab1da2d1fae6a6866942.jpg?v=tbs)