#hwslider{width: 100%;height:auto;min-height: 120px;margin:40px auto; position: relative; overflow: hidden;}
#hwslider ul{width: 100%; height:100%; position: absolute; z-index: 1}
#hwslider ul li{display:none;position:absolute; left:0; top:0; width: 100%;height:100%; overflow: hidden;}
#hwslider ul li.active{display: block;}
#hwslider ul li img{max-width: 100%}
#dots{position: absolute; bottom:20px; left:200px; min-width:60px; height: 12px; z-index: 2;}
#dots span{float: left; width:12px;height: 12px; border: 1px solid #fff; border-radius: 50%; background: #333; margin-right: 8px; cursor: pointer;}
#dots span.active{background:orangered}
.arr{display:none;position: absolute; top: 140px; z-index: 2;width: 40px; height: 40px; line-height: 38px; text-align: center;; font-size: 36px; background: rgba(0,0,0,.3); color: #fff; text-decoration: none}
.arr:hover{background: rgba(0,0,0,.7); text-decoration: none;}
#hwslider:hover .arr{display: block; text-decoration: none;color: #fff}
#prev{left: 20px}
#next{right: 20px}
$(function(){
var slider = $("#hwslider");
var dots = $("#dots span"),
prev = $("#prev"),next = $("#next");
var sliderInder = slider.children('ul')
var hwsliderLi = sliderInder.children('li');
var hwsliderSize = hwsliderLi.length; //滑块的总个数
var sliderWidth = 600; //滑块初始宽度
var sliderHeight = 320; //滑块初始高度
var index = 1; //初始显示第一个滑块
var speed = 400; //滑动速度
var interval = 3000; //间隔时间
var dotShow = true; //是否显示可切换的导航圆点
var autoPlay = false; //是否支持自动滑动
var clickable = true; //是否已经点击了滑块在做滑动动画
//初始化组件
var resize = function(){
var sWidth = slider.width();
var dotWidth = hwsliderSize*20;
var dotOffset = (sWidth-dotWidth)/2;
var sHeight = sliderHeight/sliderWidth*sWidth;
slider.css('height',sHeight);
$("#dots").css('left',dotOffset+'px'); //导航圆点位置
var arrOffset = (sHeight-40)/2;
$(".arr").css('top',arrOffset+'px'); //导航箭头位置
}
resize();
$(window).resize(function(){
resize();
});
});
var mouseX = 0,
touchStartY = 0,
touchStartX = 0;
hwsliderLi.on({
//触控开始
'touchstart': function(e) {
touchStartY = e.originalEvent.touches[0].clientY;
touchStartX = e.originalEvent.touches[0].clientX;
},
//触控结束
'touchend': function(e) {
var touchEndY = e.originalEvent.changedTouches[0].clientY,
touchEndX = e.originalEvent.changedTouches[0].clientX,
yDiff = touchStartY - touchEndY,
xDiff = touchStartX - touchEndX;
if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {
if ( xDiff > 5 ) {
if(index >= hwsliderSize){
index = 1;
}else{
index += 1;
}
moveTo(index,'next');
} else {
if(index == 1){
index = hwsliderSize;
}else{
index -= 1;
}
moveTo(index,'prev');
}
}
touchStartY = null;
touchStartX = null;
},
//触控移动
'touchmove': function(e) {
if(e.preventDefault) { e.preventDefault(); }
}
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有