简体   繁体   English

IE8 及以下使用 jQuery 循环的透明 PNG (24) 问题

[英]Transparent PNG (24) issue in IE8 and below using jQuery Cycle

I'm using jQuery cycle to fade my slideshow in / out.我正在使用 jQuery 循环来淡入/淡出我的幻灯片。

My slides have a background, and their are semi-transparent PNG's (using tag) within my slides.我的幻灯片有背景,它们在我的幻灯片中是半透明的 PNG(使用标签)。 While the slide is fading in, the semi-transparent areas have black splotches.当幻灯片淡入时,半透明区域有黑色斑点。 These splotches disappear after the slide has fully faded in.这些斑点在幻灯片完全淡入后消失。

I've gotten around this sort of thing using using AlphaImageLoader within the CSS, but these cannot be background images.我已经在 CSS 中使用 AlphaImageLoader 解决了这类问题,但这些不能是背景图像。

Any thoughts?有什么想法吗? If needed, I can setup a demo.如果需要,我可以设置一个演示。

Thanks in advance for any help!提前感谢您的帮助!

I've simplified it and uploaded an example here:我已经对其进行了简化并在此处上传了一个示例:

http://dustland.markrichterjr.com/cycle/sample.html http://dustland.markrichterjr.com/cycle/sample.html

HTML HTML

            <ul class="trending-slides">
                <li>
                    <a href="#"><img src="assets/images/home-trending-phones.png" alt="Phones" /></a>
                    <div class="text">
                        <a class="headline" href="#"><img src="assets/images/home-trending-headline.png" alt="" /></a>
                        <a class="learnmore" href="#">Learn More</a>
                        <p><a href="#">"Lorem ipsum dolor sit amet, consectetur adipisicing
                        elit, sed do eiusmod tempor incididunt ut."</a></p>
                    </div>
                </li>
                <li>
                    <img src="assets/images/home-trending-tablets.png" alt="Tablets" />
                    <div class="text">
                    <div class="text">
                        <a class="headline" href="#"><img src="assets/images/home-trending-headline.png" alt="" /></a>
                        <a class="learnmore" href="#">Learn More</a>
                        <p><a href="#">"Lorem ipsum dolor sit amet, consectetur adipisicing
                        elit, sed do eiusmod tempor incididunt ut."</a></p>
                    </div>
                </li>
                <li>
                    <img src="assets/images/home-trending-accessories.png" alt="Accessories" />
                    <div class="text">
                    <div class="text">
                        <a class="headline" href="#"><img src="assets/images/home-trending-headline.png" alt="" /></a>
                        <a class="learnmore" href="#">Learn More</a>
                        <p><a href="#">"Lorem ipsum dolor sit amet, consectetur adipisicing
                        elit, sed do eiusmod tempor incididunt ut."</a></p>
                    </div>
                </li>
                <li>
                    <img src="assets/images/home-trending-support.png" alt="Support" />
                    <div class="text">
                        <a class="headline" href="#"><img src="assets/images/home-trending-headline.png" alt="" /></a>
                        <a class="learnmore" href="#">Learn More</a>
                        <p><a href="#">"Lorem ipsum dolor sit amet, consectetur adipisicing
                        elit, sed do eiusmod tempor incididunt ut."</a></p>
                    </div>
                </li>
            </ul>

CSS CSS

            .home-page-content .most-viewed .trending-slides, .home-page-content .most-viewed .trending-slides li {
                width:630px;
                height:124px;
                margin:0;
                padding:0;
                overflow:hidden;
                list-style:none;
                background:transparent !important;
            }
            .home-page-content .most-viewed .trending-slides li {
                background:url(../images/bg-home-trending.jpg) no-repeat 100% 0;
            }

JavaScript JavaScript

    $('.home-page-content .most-viewed .trending-slides').cycle({
        fx: 'fade',
        before: function(currSlideElement, nextSlideElement) {},
        speedIn: 250,
        speedOut: 100,
        after: function(currSlideElement, nextSlideElement) {
            $('.text', nextSlideElement).show('fade', 125);
            $('.text', currSlideElement).hide();
        },
        sync: false,
        timeout: 0,
        pagerEvent: 'mouseover',
        pager: '.trending-nav',
        pagerAnchorBuilder: function(idx, slide) {
            // return selector string for existing anchor
            return '.trending-nav li:eq(' + idx + ') a';
        },
        cleartype: true,
        cleartypeNoBg: false
    });

What is happening in your application is that IE7 is applying the alpha filter to your PNG, and is then asked by jQuery to apply another alpha filter for the fade.您的应用程序中发生的情况是 IE7 将 alpha 过滤器应用于您的 PNG,然后 jQuery 要求应用另一个 alpha 过滤器进行淡化。 This has visible results like you said.正如你所说,这有明显的结果。

The way to get around this is to nest your png inside a container and then fade the container.解决这个问题的方法是将你的 png 嵌套在一个容器中,然后淡化容器。

Full answer was given by Darko Z Darko Z给出了完整的答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM