jQuery이지만 앵커를 사용한 이미지 회전은 동일하게 유지됩니다
-
16-09-2019 - |
문제
jQuery를 사용하여 캡션이있는 이미지 슬라이드 쇼를 설정했습니다. 전체 이미지 및 캡션 DIV는 연결된 앵커로 둘러싸여 있습니다. 슬라이드 쇼 함수가 잘 작동하더라도 어떤 이유로 앵커는 앵커가 마지막 세트와 동일하게 유지됩니다. 즉 아래 예제를 사용하여 슬라이드 쇼 컨텐츠는 "show/"에만 연결됩니다.
<div id="mainfeature">
<a href="http://www.google.com" class="show feature">
<img src="http://union.ic.ac.uk/arts/mtsoc/wp-content/uploads/2009/07/sweetcharity_front.png" />
<div class="caption">
<span class="tag">2009 Tour Show</span>
<span class="title">Sweet Charity</span>
<span class="detail">29th July until 8th August</span>
</div></a>
<a href="shows/" class="feature">
<img src="http://union.ic.ac.uk/arts/mtsoc/wp-content/gallery/2009-forum/Picture%20044.jpg" width="650px" />
<div class="caption">
<span class="tag">2009 Spring Show</span>
<span class="title">A Funny Thing Happened on the Way to the Forum</span>
<span class="detail"></span>
</div></a>
</div>
작업 예제를 참조하십시오 http://union.ic.ac.uk/arts/mtsoc/
당신이 가서 파헤칠 필요가 없도록 슬라이드 쇼의 JavaScript가 있습니다.
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
$('#mainfeature .caption').animate({opacity: 0.0}, 500);
//Animate the caption, opacity to 0.7
$('#mainfeature .caption').animate({opacity: 0.7}, 1000 );
}
어떤 아이디어?
해결책
앵커의 z- 인덱스는 회전 할 때 변경해야한다는 것이 밝혀졌습니다. 쇼 클래스를 사용 하여이 작업을 수행하여 JS가 변경 될 필요가 없었습니다.
제휴하지 않습니다 StackOverflow