完美兼容各大浏览器的jQuery插件实现图片切换特效_jquery
程序员文章站
2022-05-20 08:59:19
...
文件里面的功能注释也写得非常详细(详见zoeDylan.ImgChange-1.0.1.js文件),对网友们的学习是很有帮助的,虽然样式不太好看,大家可以自己写,好好利用哦。。。
(function ($) {
var//申明全局变量
_eleTemp,//缓存变量
_eleThis = $(this),//当前元素
_eleImg = $('.zd-imgChange-img'),//图片组元素
_eleControll = $('.zd-imgChange-controll'),//控制器组元素
_eleChange = $('.zd-imgChange-change'),//切换元素
_icon = '●○',//动态图标
_imgTemplate = $(document.createElement('img')),//图片模版'
_setting = {
height: 100,//高
width: 200,//宽
imgs: new Array(),//图片地址
links: null,//点击地址
tips: null,//图片说明
timers: 3000//自动切换时间
},//配置
_timers = null//自动切换保存变量
$.fn.zoeDylan_ImageChange = function (op) {
_eleThis = $(this);
_setting = $.extend(_setting, op);//设置属性
//处理数据(查看是否为合法范围)
_setting.timers = _setting.timers != null && _setting.timers != undefined && _setting.timers > 1000 ? _setting.timers : 1000;
_setting.height = parseFloat(_setting.height) _setting.width = parseFloat(_setting.width) return this.each(function () {//初始化
AddTemplate();
AddImg();
DisSize();
DisControll();
})
}
//添加模版
function AddTemplate() {
_eleThis.removeClass();
_eleThis.addClass('zd-imgChange');
_eleTemp = '
.zd-imgChange {
position: relative;
margin: auto;
padding: 0px;
min-width: 200px;
min-height: 100px;
background: rgba(0,0,0,0.5);
color: #fff;
cursor: pointer;
overflow: hidden;
}
.zd-imgChange-change {
cursor:pointer;
color:#fff;
margin: 0px;
padding: 0px;
position: relative;
background: rgba(0,0,0,0.5);
width: 10%;
height: 100%;
text-align: center;
opacity: 0.1;
z-index: 1;
-moz-transition: opacity 0.4s;
-o-transition: opacity 0.4s;
-webkit-transition: opacity 0.4s;
transition: opacity 0.4s;
border:none;
}
.zd-imgChange-change:hover {
opacity: 1;
}
.zd-imgChange-change-left {
float: left;
}
.zd-imgChange-change-right {
float: right;
}
.zd-imgChange-img {
z-index: 0;
padding: 0px;
position: absolute;
top: 0px;
left: 0px;
background: rgba(100,0,0,0.1);
width: 100%;
height: 100%;
}
.zd-imgChange-img-item {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
border: none;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-moz-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
opacity: 1;
z-index: -1;
}
.zd-imgChange-img-item-temp{
z-index:0;
}
.zd-imgChange-img-item-sel {
z-index: 1;
}
.zd-imgChange-controll {
z-index: 2;
padding: 0px;
position: absolute;
bottom: 0px;
width: 100%;
height: 20%;
background: rgba(0,0,0,0);
text-align: center;
-moz-transition: background 0.4s;
-o-transition: background 0.4s;
-webkit-transition: background 0.4s;
transition: background 0.4s;
text-shadow: 0px 0px 5px #000;
opacity: 0.7;
}
.zd-imgChange-controll:hover {
background: rgba(0,0,0,0.5);
opacity: 1;
}
.zd-imgChange-controll span {
-moz-transition: color 0.4s;
-o-transition: color 0.4s;
-webkit-transition: color 0.4s;
transition: color 0.4s;
}
.zd-imgChange-controll span:hover {
color: rgba(0,0,0,0.6);
}
http://www.w3.org/1999/xhtml">
图片切换
JS代码部分:
复制代码 代码如下:
(function ($) {
var//申明全局变量
_eleTemp,//缓存变量
_eleThis = $(this),//当前元素
_eleImg = $('.zd-imgChange-img'),//图片组元素
_eleControll = $('.zd-imgChange-controll'),//控制器组元素
_eleChange = $('.zd-imgChange-change'),//切换元素
_icon = '●○',//动态图标
_imgTemplate = $(document.createElement('img')),//图片模版'
_setting = {
height: 100,//高
width: 200,//宽
imgs: new Array(),//图片地址
links: null,//点击地址
tips: null,//图片说明
timers: 3000//自动切换时间
},//配置
_timers = null//自动切换保存变量
$.fn.zoeDylan_ImageChange = function (op) {
_eleThis = $(this);
_setting = $.extend(_setting, op);//设置属性
//处理数据(查看是否为合法范围)
_setting.timers = _setting.timers != null && _setting.timers != undefined && _setting.timers > 1000 ? _setting.timers : 1000;
_setting.height = parseFloat(_setting.height) _setting.width = parseFloat(_setting.width) return this.each(function () {//初始化
AddTemplate();
AddImg();
DisSize();
DisControll();
})
}
//添加模版
function AddTemplate() {
_eleThis.removeClass();
_eleThis.addClass('zd-imgChange');
_eleTemp = '
CSS代码部分:
复制代码 代码如下:
.zd-imgChange {
position: relative;
margin: auto;
padding: 0px;
min-width: 200px;
min-height: 100px;
background: rgba(0,0,0,0.5);
color: #fff;
cursor: pointer;
overflow: hidden;
}
.zd-imgChange-change {
cursor:pointer;
color:#fff;
margin: 0px;
padding: 0px;
position: relative;
background: rgba(0,0,0,0.5);
width: 10%;
height: 100%;
text-align: center;
opacity: 0.1;
z-index: 1;
-moz-transition: opacity 0.4s;
-o-transition: opacity 0.4s;
-webkit-transition: opacity 0.4s;
transition: opacity 0.4s;
border:none;
}
.zd-imgChange-change:hover {
opacity: 1;
}
.zd-imgChange-change-left {
float: left;
}
.zd-imgChange-change-right {
float: right;
}
.zd-imgChange-img {
z-index: 0;
padding: 0px;
position: absolute;
top: 0px;
left: 0px;
background: rgba(100,0,0,0.1);
width: 100%;
height: 100%;
}
.zd-imgChange-img-item {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
border: none;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-moz-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
opacity: 1;
z-index: -1;
}
.zd-imgChange-img-item-temp{
z-index:0;
}
.zd-imgChange-img-item-sel {
z-index: 1;
}
.zd-imgChange-controll {
z-index: 2;
padding: 0px;
position: absolute;
bottom: 0px;
width: 100%;
height: 20%;
background: rgba(0,0,0,0);
text-align: center;
-moz-transition: background 0.4s;
-o-transition: background 0.4s;
-webkit-transition: background 0.4s;
transition: background 0.4s;
text-shadow: 0px 0px 5px #000;
opacity: 0.7;
}
.zd-imgChange-controll:hover {
background: rgba(0,0,0,0.5);
opacity: 1;
}
.zd-imgChange-controll span {
-moz-transition: color 0.4s;
-o-transition: color 0.4s;
-webkit-transition: color 0.4s;
transition: color 0.4s;
}
.zd-imgChange-controll span:hover {
color: rgba(0,0,0,0.6);
}
HTML代码部分:
复制代码 代码如下:
http://www.w3.org/1999/xhtml">
ps:尽量使用高版本浏览器,目测测试浏览器:IE11 IE10 IE6 google 猎豹 欧鹏 可以完美运行,IE6透明效果有损失
代码下载:http://xiazai.jb51.net/201412/yuanma/zeodylanimgchange(jb51.net).rar
上一篇: php简单对象与数组的转换
下一篇: 3550之DHCP服务器的详尽配置实例
推荐阅读
-
Jquery实现兼容各大浏览器的Enter回车切换输入焦点的方法教程
-
jquery实现兼容浏览器的图片上传本地预览功能
-
完美兼容各大浏览器的jQuery仿新浪图文淡入淡出间歇滚动特效
-
完美兼容各大浏览器的jQuery插件实现图片切换特效
-
Jquery实现兼容各大浏览器的Enter回车切换输入焦点的方法教程
-
jQuery插件Zclip实现完美兼容个浏览器点击复制内容到剪贴板_jquery
-
完美兼容各大浏览器的jQuery插件实现图片切换特效_jquery
-
jQuery插件实现带圆点的焦点图片轮播切换_jquery
-
jQuery插件实现带圆点的焦点图片轮播切换_jquery
-
jQuery实现的图片分组切换焦点图插件_jquery