100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > html图片轮播代码 贴吧 简单的jQuery banner图片轮播实例代码

html图片轮播代码 贴吧 简单的jQuery banner图片轮播实例代码

时间:2020-12-27 15:56:11

相关推荐

html图片轮播代码 贴吧 简单的jQuery banner图片轮播实例代码

该楼层疑似违规已被系统折叠隐藏此楼查看此楼

朋友给我看了一个轮播效果,把js下载一看,丫丫的一个这么简单的效果,这么的就能写个几百行的,严重影响浏览器加载速度嘛,以为人家宽带流量不要钱玩的哦。。无奈之下给他写了个简单的,把所有代码放上去都没有超过70行,还有圆角的那个CSS,不是每个浏览器都是圆角的,不过不影响美观,嘻嘻。

先给大家展示下效果图:

无标题页

.clear{overflow:hidden; clear:both; width:0px; height:0px; }

.imgbox{width:640px; margin:0 auto; text-align:center; }

ul{padding:0px; margin:0px;}

ul li{float:left; list-style:none; }

ul li.select{display:block;}

.imgnum span{border-radius:10px; font:normal normal bold 12px/15px 微软雅黑; color:#FFF; margin-left:5px; padding:3px 6px 3px 6px; background-color:#F90; cursor:pointer;}

.imgnum span.onselect{background-color:#F00;}

.imgnum{text-align:center; float:right; margin:-30px 30px; position:relative;}

1

2

3

4

5

var time = "";

var index = 1;

$(function () {

showimg(index);

//鼠标移入移出

$(".imgnum span").hover(function () {

clearTimeout(time);

var icon=$(this).text();

$(".imgnum span").removeClass("onselect").eq(icon-1).addClass("onselect");

$("#banner_img li").hide().stop(true,true).eq(icon-1).fadeIn("slow");

}, function () {

index=$(this).text()> 4 ? 1 :parseInt($(this).text())+1;

time = setTimeout("showimg(" + index + ")", 3000);

});

});

function showimg(num) {

index = num;

$(".imgnum span").removeClass("onselect").eq(index-1).addClass("onselect");

$("#banner_img li").hide().stop(true,true).eq(index-1).fadeIn("slow");

index = index + 1 > 5 ? 1 : index + 1;

time = setTimeout("showimg(" + index + ")", 3000);

}

注意要引用 Jquery 文件,图片我就不放上来了,自己替换掉,注意图片长宽。

以上所述是小编给大家分享的简单的jQuery banner图片轮播实例代码,希望对大家有所帮助!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。