从外部加载时 jQuery fadeIn IE Png 问题

发布于 2024-08-12 20:37:50 字数 387 浏览 9 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

镜花水月 2024-08-19 20:37:50

没有任何 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

离鸿 2024-08-19 20:37:50

我在淡入具有透明 png 背景的元素时遇到了类似的问题。经过一番研究,我找到了这个页面,最后你会找到一个解决方案,这对我有帮助:

http://www.sitepoint.com/forums/showthread.php?590295-jQuery-fadein-fadeout-of-transparent- png-in-IE7-and-Chrome

用户 dan.tello 在 IE 中使用了附加过滤器 (CSS):

.item img {
  background: transparent;
  -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF)"; /* IE8 */   
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);   /* IE6 & 7 */      
  zoom: 1; }

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:

.item img {
  background: transparent;
  -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF)"; /* IE8 */   
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);   /* IE6 & 7 */      
  zoom: 1; }
苏佲洛 2024-08-19 20:37:50

编辑:我来发帖说这是没有希望的,但实际上有些人描述了解决方法。看看这是否有帮助:

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

尐籹人 2024-08-19 20:37:50

我也有类似的问题。我需要根据用户输入将几个透明 PNG 之一加载到我的页面中,并使其淡入。我最终使用了 Drew Diller 的迟来的 PNG 修复(适用于 IE6)。当然,在文档就绪时调用不适用于动态内容,因此我的脚本如下所示:

html = '<img src="selectedimage.png" />';
$('#overlay').html(html);
DD_belatedPNG.fix('#overlay img');
$('#overlay img').hide().fadeIn(1200);

它在 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:

html = '<img src="selectedimage.png" />';
$('#overlay').html(html);
DD_belatedPNG.fix('#overlay img');
$('#overlay img').hide().fadeIn(1200);

It's working great in IE7, but I haven't tested IE8 yet.

稍尽春風 2024-08-19 20:37:50

您可以为 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.

热情消退 2024-08-19 20:37:50

@jdln - 我不确定这是否是她想要的并解释错误,或者这是另一个解决方案,但这对我有用:

  1. 将透明PNG应用到包装元素
  2. 将淡入淡出应用到内部元素包装纸。这似乎也强制显示包装元素。
  3. 隐藏包装元素,使用 jQuery fade 显示内容元素

例如:

/* HTML: */
<div id="wrapper">
    <div id="content">I use this for a drop-down menu with a transparent PNG shadow for lte IE8 browsers
    </div>
</div>

/* CSS */
#wrapper{margin-left:-9999px;}

/* jQuery */  
$('#content').hide().fadeIn();

我使用 .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:

  1. Apply the transparent PNG to a wrapper element
  2. Apply your fade to an element INSIDE the wrapper. This seems to force the wrapper element to display as well.
  3. Hide the wrapper element, show the content element using jQuery fade

For example:

/* HTML: */
<div id="wrapper">
    <div id="content">I use this for a drop-down menu with a transparent PNG shadow for lte IE8 browsers
    </div>
</div>

/* CSS */
#wrapper{margin-left:-9999px;}

/* jQuery */  
$('#content').hide().fadeIn();

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!

蒗幽 2024-08-19 20:37:50

您所要做的就是使元素周围的包装器(样式)(#outer(有背景png))将js文件中的不透明度淡化为1.0。效果很好!

例如:

js 文件:

$('#style').fadeIn('slow');

css 文件:

#style
{
    margin:0;
    background:transparent;
    float:left;
}

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:

$('#style').fadeIn('slow');

css file:

#style
{
    margin:0;
    background:transparent;
    float:left;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文