jQuery悬停效果使用不透明度,IE不支持
以下是我在此页面上使用的代码: 此处
$(document).ready(function(){
$('.jcarousel-skin-tango a').hover(
function() {
$(this).find('.rollover').stop().fadeTo(500, 1);
},
function() {
$(this).find('.rollover').stop().fadeTo(500, 0);
}
)
});
问题出在 IE 8 及以下版本中。当您将鼠标悬停在任何幻灯片图像上时,悬停会变为黑色(因为 IE 不支持“不透明度”)。我基本上需要一种新的编写方式,以便在 IE 中不出现灰/黑框的情况下实现相同的效果。有什么想法吗?
Below is my code for use on this page: here
$(document).ready(function(){
$('.jcarousel-skin-tango a').hover(
function() {
$(this).find('.rollover').stop().fadeTo(500, 1);
},
function() {
$(this).find('.rollover').stop().fadeTo(500, 0);
}
)
});
The problem lies within IE 8 and below. When you hover over any of the slide images, the hover turns to black (because IE doesn't support 'opacity'). I basically need a new way of writing this so the same effect is achieved without a grey/black box appearing in IE. Any ideas ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
AFAIK,没有办法解决 IE 的问题,至少在你的情况下是这样。
Internet Explorer 不能很好地处理 javascript/jQuery 不透明度更改(通常是 Alpha 混合、show();包括函数),尤其是在使用(半)透明图像时。
IE 无法掌握 alpha 混合元素的淡入淡出。
我的建议:使用slideDown/slideUp/其他函数,或者元素属性上的.animate来获得最接近的效果,而不使用alpha混合。
祝你好运。
AFAIK, there is no way to deal with IE's problem, at least not in your case.
Internet Explorer doesn't play well with javascript/jQuery opacity changes (alpha blending generally, show(); function included), especially when using (semi)transparent images.
IE can't grasp fading of an alpha-blended element.
My suggestion: use slideDown/slideUp/other functions, or .animate on element properties to get the closest effect without using alpha blending.
good luck.
这与透明 png 无关。我有类似的问题。只需在过渡之前在元素上设置背景颜色(您可以在过渡之后立即将其删除)。
在你的样式表上:
This is not about transparent pngs. I had a similar problem. Just set a background-color on the element right before the transition (and you can remove it right after).
On your stylesheet:
你也使用半透明PNG吗?这让事情变得更加复杂。我将其更改为 + 图标的 gif 和淡入淡出的“框”的背景颜色。先尝试一下,然后再尝试用 PNG 解决它。我也遇到过同样的问题,不过如果你一步一步来的话,会更容易解决。
Are you using a semi-transparent PNG as well? That further complicates things. I'd change that to a gif for the + icon and just a background-color for the "box" that fades in and out. Try that first, then try to solve it with a PNG later. I've had the same problem, but it's easier to solve if you go at it step by step.
IE 不太支持 CSS 不透明度。使用以下代码使不透明度在 IE 中工作:
此代码允许您(例如)将具有类
foo
的所有图像设置为使用不透明度:50。您可以尝试使用
初始化元素visibility:hidden;
然后使其可见并在激活时消失。 jQuery 淡入淡出效果将与支持它的浏览器一起使用,并且如果淡入淡出未得到正确支持,则仅显示元素。此外,您可能需要考虑每个元素只运行 bling 一次,这将加快 jQuery 处理速度:
例如:
ID 选择总是最快的,其次是标签名称(a、ul、div)。 CSS 类选择速度较慢。
IE does not support the CSS opacity very well. Use the following to make opacity work in IE:
This code allows you to (for example) set all images with the class:
foo
to use opacity: 50.You may try initializing the element with
visibility:hidden;
and then making it visible and fade when it's activated. The jQuery fade effect will work with the browser that supports it and just display the element if fade isn't properly supported.Additionally, you might want to consider only running bling once per element, this will speed up the jQuery processing:
e.g.:
ID selections are always fastest, followed by tag names (a, ul, div). CSS class selections are slower.
我认为你正在使用透明的 png 图像。这不是一个不透明的问题。你必须使用 alpha imageloader for ie,它才能工作。如果你的图像被设置为CSS背景,黑客将在下面
,或者你可以使用javascript解决方案即时修复pngfix与javascript,http://www.dillerdesign.com/experiment/DD_belatedPNG/
i think you are using transparent png images. it is not an opacity issue. you must use alpha imageloader for ie, it will work. if your image is set as background from css, the hack would be below
or you can use a javascript solution for pngfix on the fly with javascript, http://www.dillerdesign.com/experiment/DD_belatedPNG/