我正在为我的公司管理一个由其他人制作的网站(24,000 美元),我们编辑了幻灯片,该幻灯片的图像底部有按钮,可以导航到相应的照片。我们所做的是在幻灯片中添加一个带有链接和按钮的图像。问题是它在 chrome 中工作正常但在 I.E. 中不行。在 I.E.按钮在那里,但最后一个按钮只给出一个空白图像(我们添加的图像放在第一个按钮中)。它还在第一个(添加的)图像周围给出了一个奇怪的边框。这是 HTML。新的第一张图片有一个链接,而其他图片没有。我查看了 javascript 和 jquery,它似乎没有规定允许使用多少图像/按钮或任何内容。很抱歉代码太长,感谢您抽出时间阅读。
<a href="http:\\www.supplysourceoutlet.com" target="_blank">
<img src="/images/home-slideshow/photo-outlet.jpg" alt="" width="684" height="325"></a>
<img src="/images/home-slideshow/photo-01.jpg" alt="" width="684" height="325">
<img src="/images/home-slideshow/photo-02.jpg" alt="" width="684" height="325">
<img src="/images/home-slideshow/photo-03.jpg" alt="" width="684" height="325">
<img src="/images/home-slideshow/photo-04.jpg" alt="" width="684" height="325">
<img src="/images/home-slideshow/photo-05.jpg" alt="" width="684" height="325">
</div>
</div>
<div class="paging">
<a href="#" rel="1"> </a>
<a href="#" rel="2"> </a>
<a href="#" rel="3"> </a>
<a href="#" rel="4"> </a>
<a href="#" rel="5"> </a>
<a href="#" rel="6"> </a>'
这是幻灯片的 javascript:
$(document).ready(function() {
//Show the paging and activate its first link
$(".paging").show();
$(".paging a:first").addClass("active");
//Get size of the image, how many images there are, then determine the size of the image reel.
var imageWidth = $(".window").width();
var imageSum = $(".image_reel img").size();
var imageReelWidth = imageWidth * imageSum;
//Adjust the image reel to its new size
$(".image_reel").css({'width' : imageReelWidth});
//Paging and Slider Function
rotate = function(){
var triggerID = $active.attr("rel") - 1; //Get number of times to slide
var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide
$(".paging a").removeClass('active'); //Remove all active class
$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
//Slider Animation
$(".image_reel").animate({
left: -image_reelPosition
}, 500 );
};
//Rotation and Timing Event
rotateSwitch = function(){
play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
$active = $('.paging a.active').next(); //Move to the next paging
if ( $active.length === 0) { //If paging reaches the end...
$active = $('.paging a:first'); //go back to first
}
rotate(); //Trigger the paging and slider function
}, 7000); //Timer speed in milliseconds (7 seconds)
};
rotateSwitch(); //Run function on launch
//On Hover
$(".image_reel a").hover(function() {
clearInterval(play); //Stop the rotation
}, function() {
rotateSwitch(); //Resume rotation timer
});
//On Click
$(".paging a").click(function() {
$active = $(this); //Activate the clicked paging
//Reset Timer
clearInterval(play); //Stop the rotation
rotate(); //Trigger rotation immediately
rotateSwitch(); // Resume rotation timer
return false; //Prevent browser jump to link anchor
});
});
最佳答案
边框的原因和只有第一个(添加的)链接是因为它是唯一一个周围有标签的链接。您可以向 img 标签添加 border="0"以去除边框,如下所示:
<a href="http:\\www.supplysourceoutlet.com" target="_blank">
<img src="/images/home-slideshow/photo-outlet.jpg" alt="" border="0" width="684" height="325">
</a>
要修复另一部分,我需要知道带有 image_reel 类的 div 的位置,你能发布更多你的 html 吗?
关于javascript - 带按钮的幻灯片图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24268782/