javascript - js div 覆盖在 IE 中不起作用

标签 javascript internet-explorer

我有这个 div,当您将鼠标悬停在上面时,它会覆盖图像以将它们着色为蓝色。效果很好!除了 - 它似乎在 IE 中根本不起作用。

有什么想法吗?

js http://www.rollinleonard.com/elements/overlaymouseover.js

页面 http://www.rollinleonard.com/elements

谢谢!

最佳答案

IE 还不支持 rgba。 IE9 beta 可以。在您的情况下,由于叠加层上没有任何文本,因此无需设置背景不透明度。只需在 #overlay 上设置常规不透明度即可。

#overlay{
   ...
   background-color: rgb(0, 0, 255);
   -moz-opacity:.60; filter:alpha(opacity=60); opacity:.60;
   ...
}

更新:正如您提到的,点击不会到达链接。一种方法是向叠加层添加处理程序,复制底层链接。

  $(window).load(function(){
      var $overlay = $('#overlay');     
      $('img').bind('mouseenter', function () {
          var $this = $(this);
          if ($this.not('.over')) {
              $this.addClass('over');
              $overlay.css({
                  width  : $this.css('width'),
                  height : $this.css('height'), 
                  top    : $this.offset().top + 'px',
                  left   : $this.offset().left + 'px',
              }).show();
              // This is hacked up,could be better, but works, it replaces the handler
              // everytime you display it
              $overlay.onclick = function() {
                   location.href = $this.getAttribute('href');
              }
          }
       }).bind('mouseout', function () {
           $(this).removeClass('over');
       });
  });

关于javascript - js div 覆盖在 IE 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5264668/

相关文章:

javascript - TypeError : fs. readdirSync 不是函数 React js

javascript - 在 Plain JS Script 之前和之后加载 ES6 模块依赖项

Javascript "imageflow"IE 未加载,在其他浏览器中速度慢

javascript - Internet Explorer 7+8 错误 - jQuery .ajax

css - IE : Avoid always downloading font? 中的@font-face

javascript - 如何将选定的 div 置于所有其他 div 之上

javascript - 如何找到最佳数字组合以获得最大和?

javascript - 如何创建受密码保护的网站?

html - Internet Explorer 使用错误的屏幕宽度进行 Bootstrap

javascript - Internet Explorer 8 中的 HTML5 和 CSS3 功能