我正在尝试制作一个简单的幻灯片,并且在使用 internet explorer 7 时遇到了一些困难。
导航默认隐藏,以防用户没有 js。如果它们滑动,那么一个箭头会淡入淡出,它在除 ie7 之外的所有浏览器中都能完美运行。在 ie7 中,整个幻灯片会跳下几个像素 - 我相信这与显示有关:没有设置,然后在淡入淡出时更改,但我不太明白。
HTML:
<div class="wrap">
<nav class="home-slideshow">
<a href="#" onclick="return false"><img src="img/arrow-left.gif" class="arrow-left" height="22" width="13"></a>
<a href="#" onclick="return false"><img src="img/arrow-right.gif" class="arrow-right" height="22" width="13"></a>
</nav>
<ul class="home-slideshow">
<li>
<a href="#"><img src="img/slide.jpg" alt="slide" title="slide" height="302" width="960"></a>
</li>
<li>
<a href="#"><img src="img/slide.jpg" alt="slide" title="slide" height="302" width="960"></a>
</li>
<li>
<a href="#"><img src="img/slide.jpg" alt="slide" title="slide" height="302" width="960"></a>
</li>
</ul>
</div> <!-- end wrap -->
JS:
// home feature slideshow
// add navigation
$('.arrow-right').show();
// navigation
$('.arrow-right').on('click', (function() {
if ($(':animated').length) {
return false;
}
ul = $('ul.home-slideshow');
noOfSlides = 3;
width = noOfSlides * 960;
lastSlide = width - 960;
currentPos = parseInt(ul.css('margin-left'));
ul.css('width', width);
ul.animate({
"margin-left": currentPos - 960
}, 1500, "easeInOutQuint", function() {
if (ul.css('margin-left') == '-' + lastSlide + 'px') {
$('.arrow-right').fadeOut();
} else {
$('.arrow-left').fadeIn();
} // end if
}); // end animate
})); // end arrow-right click
$('.arrow-left').on('click', (function() {
if ($(':animated').length) {
return false;
}
ul = $('ul.home-slideshow');
noOfSlides = 3;
width = noOfSlides * 960;
lastSlide = width + 960;
currentPos = parseInt($(ul).css('margin-left'));
ul.css('width', width);
ul.animate({
"margin-left": currentPos + 960
}, 1500, "easeInOutQuint", function() {
if (ul.css('margin-left') == '0px') {
$('.arrow-left').fadeOut();
} else {
$('.arrow-right').fadeIn();
} // end if
}); // end animate
})); // end arrow-left click
CSS:
/* Feature Slideshow */
ul.home-slideshow {
height: 302px;
overflow: hidden;
}
ul.home-slideshow li {
float: left;
}
/* Navigation */
nav.home-slideshow {
position: relative;
width: 960px;
}
.arrow-left, .arrow-right {
background: #003592;
-moz-box-sizing: content-box;
box-sizing: content-box;
display: none;
height: 22px;
padding: 6px;
top: 126px;
position: absolute;
width: 13px;
z-index: 1;
}
.arrow-right {
right: 0px;
}
.arrow-left {
left: 0px;
}
任何人都可以建议解决此问题吗?