从外部加载时 jQuery fadeIn IE Png 问题
我使用 jQuery 中的加载内容方法将域内外部 html 文件的数据加载到网页上的 div 中。我将 div 从新页面中取出,同时通过淡出该 div 并淡入新页面来隐藏当前页面中的 div。这两个 div 中都有一张 png 图像,它在 IE 中创建了可怕的黑色斑点,工作正常在其他浏览器中,但由于 IE 无法处理多个过滤器,因此造成了混乱。
我尝试使用单位 png 修复无济于事,有没有人有任何修复或想法来帮助我的 png 在此过渡期间看起来不错?
i46.tinypic.com/t9dtvr.jpg 这是问题的屏幕截图,欢呼声
还发现页面上原来的 png(在加载新内容之前)使用单位 png 修复完美地淡入和淡出,但加载的内容和然后从外部文件中退出则不然。我也向这些页面添加了修复程序,但这也不起作用。
I am loading data from external html files within my domain into a div on my webpage using a load content method in jQuery. I take the div out of the new page whilst hiding the div in the current page by fading this out and fading the new one in. There is a png image in both of these divs and it is creating horrid black blobs in IE, works fine in other browsers but due to IEs inability to process multiple filters its making a mess.
I tried using the unit png fix to no avail, does anyone have any fixes or ideas to help keep my pngs looking nice during this transition?
i46.tinypic.com/t9dtvr.jpg this is a screenshot of the problem, cheers
also discovered that the png that is on the page originaly (before loading anything new) fades in and out perfectly using the unit png fix but stuff loading in and then back out from external files doesnt. Ive added the fix to those pages too but that doesnt work either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
没有任何 100% 的解决方案。如果 PNG 中有半透明区域,则应用的任何滤镜都会使这些区域完全不透明。我见过的大多数淡入淡出过渡都会在淡入淡出过程中应用滤镜,然后再删除滤镜。这意味着当图像淡入时您将看到锯齿区域,但在过渡结束时看起来会很好。
另一种解决方案可用于静态页面的部分:如果图像后面的背景是静态的,您可以从该背景创建图像并将其用作 img 标签的背景图像。然后,淡入和淡出就可以了。如果 png 图像已经是某个元素的背景图像,则需要将其放入具有不透明背景图像集的容器中,然后将其淡化。
如果您在文本或动态内容前逐渐消失,则您无能为力。
编辑:以下页面似乎有一个涉及旧的 AlphaImageLoader 过滤器和具有不透明度过滤器集的父 div 的解决方案:
http://blog.mediaandme.be/?ref=17
There isn't any 100% solution to the problem. If you have semi transparent areas of a PNG, any filters applied will render those areas fully opaque. Most fading transitions I've seen apply the filter during the fade, then remove the filter afterwards. This means you will see the aliased areas while the image fades in but it will look fine at the end of the transition.
Another solution can be used for parts of a page that are static: If the background behind the image is static you can create an image from that background and use it as the background image of your img tag. Then, fading in and out will work just fine. If the png image is already the background image of an element, you will need to put it in a container with the opaque background image set and fade that instead.
If you're fading in front of text or dynamic content, there's not much you can do.
EDIT: The following page seems to have a solution involving the old AlphaImageLoader filter and a parent div with the opacity filter set:
http://blog.mediaandme.be/?ref=17
我在淡入具有透明 png 背景的元素时遇到了类似的问题。经过一番研究,我找到了这个页面,最后你会找到一个解决方案,这对我有帮助:
http://www.sitepoint.com/forums/showthread.php?590295-jQuery-fadein-fadeout-of-transparent- png-in-IE7-and-Chrome
用户 dan.tello 在 IE 中使用了附加过滤器 (CSS):
I had a similar problem with fading in elements with a transparent png-background. After some research I found this page, where at the end you'll find a solution, that helped me:
http://www.sitepoint.com/forums/showthread.php?590295-jQuery-fadein-fadeout-of-transparent-png-in-IE7-and-Chrome
The user dan.tello used additional filters (CSS) in IE:
编辑:我来发帖说这是没有希望的,但实际上有些人描述了解决方法。看看这是否有帮助:
http://groups .google.com/group/jquery-dev/browse_thread/thread/1f693c5f4e8ea650/f3bc9685ccb40e70?pli=1
http://blogs.msdn.com/ie/archive/ 2005/04/26/412263.aspx
EDIT: I came to post that it's hopeless, but there are actually some people describing work-arounds. See if this helps:
http://groups.google.com/group/jquery-dev/browse_thread/thread/1f693c5f4e8ea650/f3bc9685ccb40e70?pli=1
http://blogs.msdn.com/ie/archive/2005/04/26/412263.aspx
我也有类似的问题。我需要根据用户输入将几个透明 PNG 之一加载到我的页面中,并使其淡入。我最终使用了 Drew Diller 的迟来的 PNG 修复(适用于 IE6)。当然,在文档就绪时调用不适用于动态内容,因此我的脚本如下所示:
它在 IE7 中运行良好,但我还没有测试 IE8。
I was having a similar problem. I needed to load one of several transparent PNGs into my page based on user input, and have it fade in. I ended up using Drew Diller's Belated PNG fix (intended for IE6). Calling at document ready doesn't work for dynamic content of course, so here's what my script looks like:
It's working great in IE7, but I haven't tested IE8 yet.
您可以为 png 图像(或褪色的元素)指定除透明之外的
background-color
值吗?这主要是有帮助的。Can you give the png image (or the element that is faded) a
background-color
value other than transparent? That mostly hels.@jdln - 我不确定这是否是她想要的并解释错误,或者这是另一个解决方案,但这对我有用:
例如:
我使用 .hide() 来确保效果每次都从头开始,因为我从悬停事件中调用它。
希望这有帮助!
@jdln -- I'm not sure if this is what she was going for and explained it wrong, or if this is another solution, however this worked for me:
For example:
I use .hide() to make sure that the effect starts from the beginning every time, as I'm calling this from a hover event.
Hope this helped!
您所要做的就是使元素周围的包装器(样式)(#outer(有背景png))将js文件中的不透明度淡化为1.0。效果很好!
例如:
js 文件:
css 文件:
all you have to do is make the wrapper(style) around the element(#outer(has background png)) fade the opacity to 1.0 in js file. works great!
ex:
js file:
css file: