+ -
当前位置:首页 → 问答吧 → jq让图片(fadeIn)渐显,ie下连接不能点击

jq让图片(fadeIn)渐显,ie下连接不能点击

时间:2009-06-04

来源:互联网

复制代码
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. <title>无标题文档</title>
  6. <style type="text/css">
  7. img{border:0}
  8. a{ position:relative; float:left;top:20px;left:20px; clear:both}
  9. a img{ border:1px #ccc solid; padding:2px}
  10. span{ position:absolute;top:-10px;left:-10px; float:left;width:53px; height:90px; display:none}
  11. a:hover{ background:#fff}
  12. </style>
  13. </head>
  14. <body>
  15. <div class="imgs">
  16. <a href="http://blueidea.com" target="_blank"><img src="http://bbs.jquery.org.cn/p_w_upload/2_17971_674fd1b9826382d.jpg" alt="blueidea"/><span><img src="http://bbs.jquery.org.cn/p_w_upload/2_17971_7bc59b39b6fd421.jpg" alt="blueidea"/></span></a>
  17. </div>
  18. <script src="http://jqueryjs.googlecode.com/files/jquery-1.3.min.js" type="text/javascript"></script>
  19. <script type="text/javascript">
  20. jQuery.noConflict();
  21. jQuery(
  22. function(){
  23. jQuery(".imgs > a").mouseover(function(){
  24. jQuery("span",this).stop();
  25. jQuery("img",this).not("span > img").stop();
  26. jQuery("img",this).not("span > img").fadeTo("slow", 0);
  27. jQuery("span",this).css({display:'block',opacity:'0'});
  28. jQuery("span",this).fadeTo("slow", 1);
  29. }
  30. );
  31. jQuery(".imgs > a").mouseout(function(){
  32. jQuery("span",this).stop();
  33. jQuery("img",this).not("span > img").stop();
  34. jQuery("span",this).css({display:'none'});
  35. jQuery("img",this).not("span > img").fadeTo("slow", 1);
  36. })
  37. })
  38. </script>
  39. </body>
  40. </html>


jq刚学着用,出现这个问题,谁帮忙看下,谢谢啊
图片:
图片:
ie的bug,经测试当内嵌元素设置了position或float属性时会挡住外围的a标签

修正方法是将这个元素的z-index设为负的,不过其他浏览器不需要,所以用*z-index:-1;

span{ *z-index:-1;position:absolute;top:-10px;left:-10px; float:left;width:53px; height:90px; display:none}

此外,既然已经position:absolute了,就没必要float:left了

作者: kouyubo   发布时间: 2009-06-04

相关阅读 更多