【问题标题】:Disappearing images in IE8 jQuery Cycle在 IE8 jQuery Cycle 中消失的图像
【发布时间】:2012-01-03 21:52:04
【问题描述】:

http://www.lunatestsite.co.uk/products/lifestation

我这辈子都无法解决这个问题。到目前为止只在 IE8 中。我在主页周期中遇到了同样的问题,但设法通过声明宽度、高度和背景来解决:none !important 在有问题的 img 上。

我认为这可能是 png 问题,但 jpg 也是如此:

http://www.lunatestsite.co.uk/test-disappearing-jpgs

相同的结果:幻灯片中两个图像中的第一个通常闪烁,然后消失。

任何想法都值得赞赏。

已解决:我最初的修复方法最终也解决了这个问题:添加背景:不重要!,并声明宽度/高度。它不适用于其他模板,因为我使用的是类而不是 ul#product-images 的 id。

耻辱,它燃烧!很抱歉浪费了大家的时间。

body.home #front-slider #front-slides .slide{
background:none !important;
width: 980px;
height: 389px;
}

body.home #front-slider #front-slides .slide .slide-image img{
    background:none !important;
    width: 629px;
    height: 345px;
}

body.page-template-page-product-view-php ul#product-images .slide, body.page-template-page-product-view-wide-php ul#product-images .slide{
    background:none !important;
    width: 970px;
    height: 300px;
}

【问题讨论】:

  • CSS3Pie 帮助我们不再讨厌 IE:css3pie.com
  • CSS3Pie 对此有何帮助?抱歉,没有看到连接。
  • css3 pie 修复了各种 IE8 CSS 怪癖。

标签: jquery internet-explorer-8 cycle


【解决方案1】:

听起来图像仍在加载中。

试试这个...

$(window).load(function() {
    $('#product-images, #front-slides').cycle({
        timeout: '7000',
        next: '#next',
        prev: '#prev',
        pager: '#pager',
        pagerAnchorBuilder: function(idx, el) {
                return '<a href="#"></a>';
            }
    });
 });

window.load() 将在 DOM 页面图像加载后触发,而 document.ready() 仅在 DOM 加载后触发。

【讨论】:

  • IE 对window.load 也很挑剔。在 DOM 加载之前/期间,图像是否以任何方式隐藏(displayvisibility)?
  • Cycle 插件只是直接将图像的父
  • 的 opacity 属性从 0 更改为 1,并将显示设置为 block 或 none 取决于它是否是当前幻灯片。
  • 我注意到 IE8 将忽略 window.load() 用于隐藏或不可见的图像。在它们再次可见之前,它们仍然不会加载。让我找到我的解决方法。
  • @luke,抱歉,我的解决方法不适用于 Cycle,因为它是我自己的插件的一部分。我建议在调用 Cycle 之前进行图像预加载。它很难看,但即使是 IE8 也可以使用。
  • 【解决方案2】:

    我也遇到了这个问题,我把它追溯到 CSS 规则

    img {
      max-width: 100%;
    }
    

    一旦我删除了上述规则(在这种情况下我不需要它),图像就会停止消失。

    【讨论】:

    • 这对我有用。 max-width: 100% 来自1140 grid,所以我不想在幻灯片之外删除它。我能够用 .slide img { max-width: inherit } 覆盖它
    • 奇迹般地,这也解决了我的问题。它应该记录在某个地方,因为max-width: 100%; 是适应移动浏览器的常用技巧。
    【解决方案3】:

    改变

    img {
        max-width: 100%;
    }
    

    img {
        max-width: auto;
    }
    

    【讨论】:

      【解决方案4】:

      如果你想保留

      max-width: 100%;
      

      然后也添加

      width: auto;
      

      或者从 HTML 中移除显式的宽度和高度属性

      或者将图片放入非浮动容器中

      或者为容器指定一个特定的宽度。

      这里有一篇关于这个错误的很好的文章:

      http://www.456bereastreet.com/archive/201202/using_max-width_on_images_can_make_them_disappear_in_ie8/

      【讨论】:

        猜你喜欢
        相关资源
        最近更新 更多
        热门标签