jQuery fadeIn fadeOut - IE8 不淡入淡出

发布于 2024-08-31 18:52:07 字数 4156 浏览 4 评论 0原文

谁能告诉我为什么 .jpg 在 IE8 中不会淡入或淡出。现在它只是消失并重新出现,不透明度没有变化。我在本地和发布服务器上进行了此设置,奇怪的是图像在本地淡入淡出效果很好,只有当我转到发布服务器时它们才停止淡出。

只是想知道我是否错过了一些人可以快速帮助我解决的问题。

这是发布服务器上的 gcRotateContent,如果我只是抛出一个图像并淡入淡出,它就可以工作,但由于某种原因,它不适用于此标记。

<div class="gcRotateContent">
   <div id="USCFRR2EN" class="gcEmployeeProfile">
      <div class="gcEmployeeProfileHeading">
         Meet John</div>
      <div class="gcEmployeeProfileContent">
         <div class="gcEmployeeProfileHRPad">
         </div>
         <div class="gcEmployeeProfileHR">
         </div>
         <div class="gcEmployeeProfileHRPad">
         </div>
         <div class="gcEmployeeProfileSLVideo">
            <img src="/PublishingImages/Profile_JOHN-190x96.jpg" alt="Portrait of employee John."
               height="96" width="190"></div>
         <div class="gcEmployeeProfileName">
         </div>
         <div class="gcEmployeeProfileTitle">
            Software Development Lead, Server Performance</div>
         <div class="gcEmployeeProfileQuote">
            “You will find no other company with the sheer breadth of technologies. The things you get to see and learn from other
            people are amazing.”</div>
      </div>
      <div class="gcEmployeeProfileFooter">
      </div>
   </div>
</div>

<div class="gcRotate">
      <div class="gcRotateContent">
         <div style="border: solid 2px black; text-align: center; width: 150px;">
            This is first content
            <img src="http://pix.motivatedphotos.com/2008/6/16/633492359109161542-Skills.jpg"
               alt="First" />
         </div>
      </div>
      <div class="gcRotateContent">
         <div style="border: solid 2px black; text-align: center; width: 150px">
            This is second content
            <img src="http://www.funnycorner.net/funny-pictures/5010/cheezburger-locats.jpg"
               alt="Second" />
         </div>
      </div>
      <div class="gcRotateContent">
         <div style="border: solid 2px black; text-align: center; width: 150px">
            This is third content
            <img src="http://icanhascheezburger.files.wordpress.com/2007/06/business.jpg" alt="Third" />
         </div>
      </div>
   </div>



   <div>
      This shouldn't move.
   </div>

   <script type="text/javascript">
      function fadeContent() {

         $(".gcRotateContent").first().customFadeOut(500, function() {
            $(".gcRotateContent:hidden:first").customFadeIn(500)
         });
         $(".gcRotateContent").first().appendTo($(".gcRotateContent").parent());
      }

      $(".gcRotate").height(0);

      $(".gcRotateContent").each(
         function() {
            if ($(".gcRotate").height() < $(this).height()) {
               $(".gcRotate").height($(this).height());
            }
         }
         );

      $(".gcRotateContent").each(function() {
         $(this).css("display", "none")
      });

      $(".gcRotate").hover(function() { window.clearInterval(timer) }, function() { timer = window.setInterval("fadeContent()", 2000) });

      $(".gcRotateContent").first().show(0);
      var timer = window.setInterval("fadeContent()", 2000);

      (function($) {
         $.fn.customFadeIn = function(speed, callback) {
            $(this).fadeIn(speed, function() {
               if (jQuery.browser.msie)
                  $(this).get(0).style.removeAttribute('filter');
               if (callback != undefined)
                  callback();
            });
         };
         $.fn.customFadeOut = function(speed, callback) {
            $(this).fadeOut(speed, function() {
               if (jQuery.browser.msie)
                  $(this).get(0).style.removeAttribute('filter');
               if (callback != undefined)
                  callback();
            });
         };
      })(jQuery);
   </script>

Can anyone tell me why a .jpg would not fade in or fade out in IE8. Right now it is just disapearing and reappearing with no opacity changes. I have this set up locally and on a publishing server, strange thing is the images fade in and out just fine locally, it's only when I go to the publishing server that they cease to fade.

Just wondering if I am missing something someone could quickly help me with off the top of their heads.

Here is the gcRotateContent that is on the publishing server, If I just throw an image up and do a fade in out it works, for some reason it doesn't work with this markup.

<div class="gcRotateContent">
   <div id="USCFRR2EN" class="gcEmployeeProfile">
      <div class="gcEmployeeProfileHeading">
         Meet John</div>
      <div class="gcEmployeeProfileContent">
         <div class="gcEmployeeProfileHRPad">
         </div>
         <div class="gcEmployeeProfileHR">
         </div>
         <div class="gcEmployeeProfileHRPad">
         </div>
         <div class="gcEmployeeProfileSLVideo">
            <img src="/PublishingImages/Profile_JOHN-190x96.jpg" alt="Portrait of employee John."
               height="96" width="190"></div>
         <div class="gcEmployeeProfileName">
         </div>
         <div class="gcEmployeeProfileTitle">
            Software Development Lead, Server Performance</div>
         <div class="gcEmployeeProfileQuote">
            “You will find no other company with the sheer breadth of technologies. The things you get to see and learn from other
            people are amazing.”</div>
      </div>
      <div class="gcEmployeeProfileFooter">
      </div>
   </div>
</div>

<div class="gcRotate">
      <div class="gcRotateContent">
         <div style="border: solid 2px black; text-align: center; width: 150px;">
            This is first content
            <img src="http://pix.motivatedphotos.com/2008/6/16/633492359109161542-Skills.jpg"
               alt="First" />
         </div>
      </div>
      <div class="gcRotateContent">
         <div style="border: solid 2px black; text-align: center; width: 150px">
            This is second content
            <img src="http://www.funnycorner.net/funny-pictures/5010/cheezburger-locats.jpg"
               alt="Second" />
         </div>
      </div>
      <div class="gcRotateContent">
         <div style="border: solid 2px black; text-align: center; width: 150px">
            This is third content
            <img src="http://icanhascheezburger.files.wordpress.com/2007/06/business.jpg" alt="Third" />
         </div>
      </div>
   </div>



   <div>
      This shouldn't move.
   </div>

   <script type="text/javascript">
      function fadeContent() {

         $(".gcRotateContent").first().customFadeOut(500, function() {
            $(".gcRotateContent:hidden:first").customFadeIn(500)
         });
         $(".gcRotateContent").first().appendTo($(".gcRotateContent").parent());
      }

      $(".gcRotate").height(0);

      $(".gcRotateContent").each(
         function() {
            if ($(".gcRotate").height() < $(this).height()) {
               $(".gcRotate").height($(this).height());
            }
         }
         );

      $(".gcRotateContent").each(function() {
         $(this).css("display", "none")
      });

      $(".gcRotate").hover(function() { window.clearInterval(timer) }, function() { timer = window.setInterval("fadeContent()", 2000) });

      $(".gcRotateContent").first().show(0);
      var timer = window.setInterval("fadeContent()", 2000);

      (function($) {
         $.fn.customFadeIn = function(speed, callback) {
            $(this).fadeIn(speed, function() {
               if (jQuery.browser.msie)
                  $(this).get(0).style.removeAttribute('filter');
               if (callback != undefined)
                  callback();
            });
         };
         $.fn.customFadeOut = function(speed, callback) {
            $(this).fadeOut(speed, function() {
               if (jQuery.browser.msie)
                  $(this).get(0).style.removeAttribute('filter');
               if (callback != undefined)
                  callback();
            });
         };
      })(jQuery);
   </script>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

随心而道 2024-09-07 18:52:07

显然有一个解决方法!

只需将绝对/相对定位元素设置为以下 css 属性:

opacity:inherit;
filter:inherit;

例如:

<div>
<img id='myImg' src='http://mydomain.com' style='position:absolute;top:10px;left:5px;filter:inherit;opacity:inherit' />
</div>

玩得开心,

Omer

Apparently there's a workaround!

Simply set the absolute/relative positioned elements the following css attributes:

opacity:inherit;
filter:inherit;

E.g:

<div>
<img id='myImg' src='http://mydomain.com' style='position:absolute;top:10px;left:5px;filter:inherit;opacity:inherit' />
</div>

Have fun,

Omer

阿楠 2024-09-07 18:52:07

我想通了,css设置position:relative在图像上,显然ie8不喜欢这样,有没有解决方法我想知道,搜索开始。

I figured it out, css setting position:relative on the image, aparently ie8 doesn't like that, is there a workaround I wonder, the search begins.

究竟谁懂我的在乎 2024-09-07 18:52:07

我刚刚遇到了这个问题,所有的 css 标记都不起作用。
淡入/淡出在 FF 和 Chrome 上有效,但在 IE8 中无效,该元素根本没有显示。
在 IE7 中,它们从不可见变为可见。

因此,为了解决我的问题,我只想在其他浏览器上保留淡入/淡出并使元素出现在 IE8 中。解决方案是像这样使用回调:

$(".elements").fadeIn("slow",function(){$(this).show()}):
$(".elements").fadeOut("slow",function(){$(this).hide()}):

这样我总是强制最终得到我想要的结果。

I just had this problem, and all the css ticks didn't worked.
The fadeIn/Out worked on FF and Chrome, but not in IE8, the element didn't showed up at all.
In IE7 they just went from invisible to visible.

So to fix my problem I just wanted to keep the fadeIn/Out on the other browsers and make the elements appear in IE8. The solution was to use the callback like so:

$(".elements").fadeIn("slow",function(){$(this).show()}):
$(".elements").fadeOut("slow",function(){$(this).hide()}):

This way I always force the result I want in the end.

美人骨 2024-09-07 18:52:07

对于快速而肮脏的修复(或者如果上面的建议不起作用,就像我的情况一样),您可以简单地用显示/隐藏替换 jQuery 的 fadeIn/fadeOut 。因此,在 html 中执行:

<!--[if IE]>
<script type="text/javascript src="ieFixes.js"></script>
<![endif]-->

并在 IE hacks 的某些 javascript 文件(例如 ieFixes.js)中输入:

jQuery.fn.fadeIn = function() {
    this.show();
}

jQuery.fn.fadeOut = function() {
    this.hide();
}

如果您要链接动画调用等,则必须对此进行一些调整。

For a quick and dirty fix (or if the suggestions above are just not working, as is my case) you can simply replace jQuery's fadeIn/fadeOut with show/hide. So in the html do:

<!--[if IE]>
<script type="text/javascript src="ieFixes.js"></script>
<![endif]-->

and in some javascript file of IE hacks (eg ieFixes.js) put:

jQuery.fn.fadeIn = function() {
    this.show();
}

jQuery.fn.fadeOut = function() {
    this.hide();
}

You'll have to tweak this a bit if you're chaining animate calls, etc.

你与昨日 2024-09-07 18:52:07

将您的图像替换为带有背景图像的 div(相同大小)并淡入/淡出该 div。

<div style="background-image:url('paper.gif');height:xxxpx;width:xxxpx"></div>

Replace your image with a div (of the same size) with a background image and fade-in/-out the div.

<div style="background-image:url('paper.gif');height:xxxpx;width:xxxpx"></div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文