2009-07-04 6 views
0

jQuery를 사용하여 이미지 슬라이드 쇼를 만들었습니다. 이미지는 서로간에 사라집니다. 각 이미지에는 캡션이 있고 각 이미지에는 자체 div가 있습니다. 이미지가 흐려짐에 따라 관련 자막이 위로 올라갑니다. 캡션은 투명하게 만들어졌으며 IE를 제외한 모든 브라우저에서 작동합니다.jQuery Image Slideshow : IE에서 캡션이 투명하지 않습니다.

웹 사이트는 http://mtsoc.enfotext.com

합니다 (슬라이드 쇼 중 하나) 자바 스크립트에서 찾을 수 있습니다 :

function slideShow() { 

    //Set the opacity of all images to 0 
    $('#mainfeature a').css({ 
     opacity: 0.0 
    }); 

    //Get the first image and display it (set it to full opacity) 
    $('#mainfeature a:first').css({ 
     opacity: 1.0 
    }); 

    //Set the caption background to semi-transparent 
    $('#mainfeature .caption').css({ 
     opacity: 0.7 
    }); 

    //Call the gallery function to run the slideshow 
    setInterval('main_gallery()', 8000); 
} 


function main_gallery() { 

    //if no IMGs have the show class, grab the first image 
    var current = ($('#mainfeature a.show') ? $('#mainfeature a.show') : $('#mainfeature a:first')); 

    //Get next image, if it reached the end of the slideshow, rotate it back to the first image 
    var next = ((current.next().length) ? ((current.next().hasClass('caption')) ? $('#mainfeature a:first') : current.next()) : $('#mainfeature a:first')); 

    //Set the fade in effect for the next image, show class has higher z-index 
    next.css({ 
     opacity: 0.0 
    }) 
     .addClass('show') 
     .animate({ 
     opacity: 1.0 
    }, 1000); 

    //Hide the current image 
    current.animate({ 
     opacity: 0.0 
    }, 1000) 
     .removeClass('show'); 

    //Set the opacity to 0 and height to 1px 
    $('#mainfeature .caption').animate({ 
     opacity: 0.0 
    }, { 
     queue: false, 
     duration: 0 
    }).animate({ 
     height: '1px' 
    }, { 
     queue: true, 
     duration: 300 
    }); 

    //Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect 
    $('#mainfeature .caption').animate({ 
     opacity: 0.7 
    }, 100).animate({ 
     height: '50px' 
    }, 500); 
} 

는 CSS는 다음과 같습니다

#mainfeature.feature { 
    color: #fff; 
    display: block; 
    position: absolute; 
    overflow: hidden; 
    z-index: 1; 
} 

#mainfeature.caption { 
    background: #333; 
    padding: 10px; 
    position: absolute; 
    left: 0; 
    bottom: 0; 
    z-index: 600; 
    height: 50px; 
    opacity: 0.7; 
    filter: alpha(opacity = 70); 
    width: 575px; 
} 

html로는 다음과 같습니다

<div id="mainfeature"> 
    <a href="#" class="show feature"> 
     <img src="<?php bloginfo('template_directory'); ?>/images/12.jpg" /> 
     <div class="caption"> 
      <span class="tag">Spring Show</span> 
      <span class="title">A Funny Thing Happened on the Way to the Forum</span> 
      <span class="detail">Through June 15</span> 
     </div> 
    </a> 
... more slides... 
</div> 

어쨌든, 긴 질문, 많은 정보. IE에서 캡션이 투명하지 않은 이유는 누구나 알 수 있습니까?

감사합니다.

답변

0

IE는 필터 CSS 속성을 구현하지 않습니다. filter : progid : DXImageTransform.Microsoft.Alpha (opacity = 0);와 같은 것을 사용해야합니다. IE의 투명성을 위해. 또는 PNG 배경 이미지를 사용하고 JS를 사용하여 투명도를 적용 할 수 있습니다. 많은 옵션이 있습니다.

0

문제는 중첩 된 불투명도 설정으로 보입니다. 당신이 개발자 도구 모음과 DOM을 탐색 할 경우

, 당신은 a.feature 태그에서

filter:alpha(opacity=100) 

를 제거하여 적절한 모양을 얻을 수 있습니다 (앵커가 표시되는 동안 수행해야합니다).

할 수있는 일이 몇 가지 있습니다. 당신이 불투명 스타일 또한

//Set the fade in effect for the next image, show class has higher z-index 
next.css({opacity: 0.0}) 
.addClass('show') 
.animate({opacity: 1.0}, 1000, null, function(){ next.removeAttr("style"); }); 

을 제거 하단에 한 줄을 추가 할 수있는 것보다 내 및 전체 앵커 페이드를해야하는 경우이 설계된대로, 당신은 fadeIn/페이드 아웃 기능 사용을 고려하실 수 있습니다 범위 내에서 불투명도를 적절히 적용 할 수 있습니다.

0

jQuery에서 불투명도를 설정하는 괜찮은 크로스 브라우저 방식은 .fadeIn/.fadeOut/.fadeTo를 사용하는 것입니다.

나는 이것이 애니메이션 된 불투명도 설정을위한 것이라는 것을 알고 있지만, 요구 사항에 맞게 타이밍을 변경할 수 있습니다. 제시된 다른 대답은보다 견고하지만 조금 더 많은 유지 보수가 필요합니다.

희망이 있습니다.

0

투명 CSS 규칙이있는 클래스가 숨겨져있는 경우 엘리먼트를 다시 표시 할 때 필터 CSS 규칙을 다시 설정해야한다는 것을 알았습니다.

은 나를 위해 일한 :

$(".selected").find(".overlay").css("filter", "alpha(opacity=80)").fadeIn(500); 
관련 문제