Internet Explorer 8 和 jQuery:click() 具有透明背景的元素
在 IE8 中,我有一个 100% 宽度 + 高度固定位置 div,#photo-upload
,具有透明背景,覆盖整个页面。我有一个用于该 div 的 click() 函数,但在 IE8 中,单击不会触发。将背景设置为纯色可以解决该问题。
有谁有此错误的经验或有解决方法吗?
$('#photo-upload').click(function(){
$('#photo-upload').removeClass('show');
});
In IE8 I have a 100% width + height fixed position div, #photo-upload
, with a transparent background, which overlays the entire page. I have a click() function for that div, but in IE8 the click does not fire. Setting the background to a solid color solves the problem.
Does anyone have experience with this bug or have a workaround?
$('#photo-upload').click(function(){
$('#photo-upload').removeClass('show');
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
添加彩色背景并设置滤镜:alpha(opacity=0); opacity: 0;
如果有人确切地发布了发生这种情况的原因,我会很感兴趣,但这是我发现可行的解决方法。
这是一个演示: http://jsfiddle.net/uMyXC/
Add a colored background and set
filter: alpha(opacity=0); opacity: 0;
I'd be interested if someone posts exactly why this happens but this is the work-around I've found to work.
Here is a demo: http://jsfiddle.net/uMyXC/
我想我会添加 j-man86 对已接受答案的评论中的答案,以防有人像我一样一开始忽略它。
使用透明、重复、1px 方形 png(或 gif,只要它是完全透明的)作为叠加 div 的背景图像。
很棒的发现!谢谢,j-man86!
Figured I'd add the answer from j-man86's comment on the accepted answer in case someone overlooks it at first like I did.
Use a transparent, repeating, 1px square png (or gif, as long as it's fully transparent) as the background image of the overlayed div.
Excellent discovery! Thanks, j-man86!
我只在 IE10 上测试过这个,但似乎有一个更简单的解决方案,带有 alpha 但没有过滤器。只需设置一个显式 alpha 分量为零的颜色似乎也能达到目的:
I have only tested this on IE10, but there seems to be a simpler solution with alpha but without filters. Just setting a color with an explicit alpha component of zero seems to do the trick as well:
这是解决该问题的简短而甜蜜的方法:
完成。 :)
This is the short and sweet way to solve that problem:
and Done. :)
只需设置不透明度为零的背景颜色:
这适用于 IE9。
Just set a background colour with zero opacity:
This works on IE9.