一个全屏的js轮播插件,非常好用,移植性好,今天用到的,收藏一下,以备使用。
源码参考(以下范例代码,直接复制到本地运行就可以了,都是写的全路径[daixiaorui,com],方便大家演示效果):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js全屏banner图片轮播插件</title>
<script type="text/javascript" src="https://www.daixiaorui.com/Public/js/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
/*首页幻灯*/
C_banner($("#banner"), $("#banner_dl"), 6000);
});
//banner
function C_banner(obj, obj1, t) {
var items = obj.find(".banner-item");
var bd_html = "", cfq = null, auto = null;
var items_length = items.length;
for (var i = 0; i < items_length; i++) {
var pic_src = items.find("img").eq(i).attr("src");
items.eq(i).css('background','url(' + pic_src + ') center center no-repeat');
bd_html += '<a href="javascript:void(0)"></a>';
}
/*daixiaorui.com*/
obj1.html(bd_html);
var tool_items = obj1.find("a");
show_item(0);
tool_items.mouseover(function() {
clearTimeout(cfq);
var _this = $(this);
cfq = setTimeout(function() {
clearTimeout(auto);
show_item(_this.prevAll().length);
}, 100);
});
tool_items.mouseout(function() {
clearTimeout(cfq);
});
function show_item(j) {
items.fadeOut("slow");
tool_items.removeClass("cur");
items.eq(j).fadeIn("slow");
tool_items.eq(j).addClass("cur");
auto_run();
};
function auto_run() {
auto = setTimeout(function() {
var x = obj1.find("a.cur").eq(0).prevAll().length;
if ((x + 1) < tool_items.length) {
show_item(x + 1);
} else {
show_item(0);
}
}, t);
};
};
</script>
<style>
/*banner*/
#banner{position:relative;height:400px;width:100%;border-top:1px solid #fff}
.banner-item{position:absolute;top:0;left:0;height:400px;width:100%;display:none}
.banner-item a{width:100%;height:400px;display:block;overflow:hidden}
.banner-item img{display:none}
.banner_dl_room{position:absolute;width:100%;height:20px;left:0;bottom:0;z-index:99}
#banner_dl{width:1000px;text-align:right;padding-right:35px;margin:0 auto}
#banner_dl a{width:27px;height:6px;background:#fff;display:inline-block;overflow:hidden;margin:0 0 0 5px}
#banner_dl a.cur{background:#0067d0}
</style>
</head>
<body>
<div class="banner" id="banner">
<div class="banner-item">
<a href='#this'><img src='https://www.daixiaorui.com/Public/uploads/201406/daixiaorui2.jpg' border='0' /></a>
</div>
<div class="banner-item">
<a href='#this'><img src='https://www.daixiaorui.com/Public/uploads/201406/daixiaorui.jpg' border='0' /></a>
</div>
<div class="banner_dl_room">
<div id="banner_dl"></div>
</div>
</div>
</body>
</html>
虽然网上也有很多js轮播的插件,但是这个更精简、更实用。
文章出自:https://www.daixiaorui.com/read/104.html 本站所有文章,除注明出处外皆为原创,转载请注明本文地址,版权所有。
蛋仔派对无限蛋币http://www.wzryzs.com/
666
666
很好的方法值得推荐
gg修改器https://www.guiyangtax.com/ 葫芦侠http://www.booj.net/ 八门神器http://www.tusovok.net/
gg修改器https://www.guiyangtax.com/ 葫芦侠http://www.booj.net/ 八门神器http://www.tusovok.net/