墨芈深夜发布插件——图片切换 附上下载地址:http://pan.baidu.com/s/17kKF3共享天地/【墨芈 插件】zoeDylan Plugins

Code

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) < 100 ? 100 : parseFloat(_setting.height);
_setting.width = parseFloat(_setting.width) < 200 ? 200 : parseFloat(_setting.width);
return this.each(function () {//初始化
AddTemplate();
AddImg();
DisSize();
DisControll();
})
}
//添加模版
function AddTemplate() {
_eleThis.removeClass();
_eleThis.addClass('zd-imgChange');
_eleTemp = '<button class="zd-imgChange-change zd-imgChange-change-left"><</button>';
_eleThis.append(_eleTemp);
_eleTemp = ' <div class="zd-imgChange-img"> </div>';
_eleThis.append(_eleTemp);
_eleTemp = ' <div class="zd-imgChange-controll"></div>';
_eleThis.append(_eleTemp);
_eleTemp = ' <button class="zd-imgChange-change zd-imgChange-change-right">></button>';
_eleThis.append(_eleTemp);
//给全局变量赋值
_eleImg = $('.zd-imgChange-img');
_eleControll = $('.zd-imgChange-controll');
_eleChange = $('.zd-imgChange-change');
}
//添加图片
function AddImg() {
for (var i = 0; i < _setting.imgs.length; i++) {
//图片
_eleTemp = $(document.createElement('img'));
_eleTemp.addClass('zd-imgChange-img-item');
_eleTemp.attr('src', _setting.imgs[i]);
_eleImg.append(_eleTemp);
//图标
_eleControll.append('<span>' + _icon[1] + '</span>');
//提示
$(_eleImg.children('img')[i]).attr({ 'title': _setting.tips[i] + '|' + _setting.links[i] });
$(_eleControll.children('span')[i]).attr('title', _setting.tips[i]);
}
Dispose(0, 'TtoB');
}
//处理尺寸
function DisSize() {
_eleThis.css({ 'height': _setting.height, 'width': _setting.width, 'font-size': _setting.height * 0.2 - 2 });
_eleThis.children('button').css('font-size', _setting.height * 0.2 - 2);
_eleChange.css({ 'line-height': _setting.height + 'px' });
}
//处理操作事件
function DisControll() {
_eleImg.children('img').bind('click', function () {//点击图片跳转
document.location = 'http://' + $(this).attr('title').split('|')[$(this).attr('title').split('|').length - 1];
});
_eleChange.bind('click', function () {//顺序切换图片
var nowImg = $('.zd-imgChange-img-item-sel');
_eleTemp = _eleImg.children('img');
if ($(this).hasClass('zd-imgChange-change-left')) {//向左切换
for (var i = 0; i < _eleTemp.length; i++) {
if (nowImg.attr('title') == $(_eleTemp[i]).attr('title')) {
if ((i - 1) < 0) {
Dispose(_eleTemp.length - 1, 'RtoL');
} else {
Dispose(i - 1, 'RtoL');
}
break;
}
}
} else if ($(this).hasClass('zd-imgChange-change-right')) {//向右切换
for (var i = 0; i < _eleTemp.length; i++) {
if (nowImg.attr('title') == $(_eleTemp[i]).attr('title')) {
if ((i + 1) > _eleTemp.length - 1) {
Dispose(0, 'LtoR');
} else {
Dispose(i + 1, 'LtoR');
}
break;
}
}
} else {
return false;
}
});
_eleControll.children('span').bind('click', function () {
for (var i = 0; i < _eleControll.children('span').length; i++) {
if ($(_eleControll.children('span')[i]).attr('title') == $(this).attr('title')) {
if ($(_eleImg.children('img')[i]).attr('src') != $('.zd-imgChange-img-item-sel').attr('src')) {//判断是否点击的同一个标签
Dispose(i, 'TtoB');
}
break;
}
}
});
}
//切换器
function Dispose(eNum, dir) {//切换图片
clearTimeout(_timers);
DisposeAnm();
$(_eleControll.children('span')).html(_icon[1]);
$(_eleControll.children('span')[eNum]).html(_icon[0]);
$('.zd-imgChange-change-left').attr('title', eNum - 1 >= 0 ? $(_eleControll.children('span')[eNum - 1]).attr('title') : $(_eleControll.children('span')[_eleControll.children('span').length - 1]).attr('title'));
$('.zd-imgChange-change-right').attr('title', eNum + 1 <= _eleControll.children('span').length - 1 ? $(_eleControll.children('span')[eNum + 1]).attr('title') : $(_eleControll.children('span')[0]).attr('title'));
_timers = setTimeout(Timers, _setting.timers);
//切换动画--根据z-index实现视觉效果
function DisposeAnm() {
$('.zd-imgChange-img-item').removeClass('zd-imgChange-img-item-temp');
$('.zd-imgChange-img-item-sel').removeClass('zd-imgChange-img-item-sel').addClass('zd-imgChange-img-item-temp');
_eleTemp = $(_eleImg.children('img')[eNum]).addClass('zd-imgChange-img-item-sel');
if (dir == 'TtoB') {
_eleTemp.css('top', -_setting.height);
_eleTemp.animate({ top: 0 }, 300);
} else if (dir == 'RtoL') {
_eleTemp.css('left', _setting.width);
_eleTemp.animate({ left: 0 }, 300);
} else if (dir == 'LtoR') {
_eleTemp.css('left', -_setting.width);
_eleTemp.animate({ left: 0 }, 300);
}
}
}
//自动切换时钟
function Timers() {
_timers = setTimeout(Timers, _setting.timers);
var nowImg = $('.zd-imgChange-img-item-sel');
_eleTemp = _eleImg.children('img');
for (var i = 0; i < _eleTemp.length; i++) {
if (nowImg.attr('title') == $(_eleTemp[i]).attr('title')) {
if ((i - 1) < 0) {
Dispose(_eleTemp.length - 1, 'TtoB');
} else {
Dispose(i - 1, 'TtoB');
}
break;
}
}
} })($)

JS代码部分

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:;
-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:;
} .zd-imgChange-change-left {
float: left;
} .zd-imgChange-change-right {
float: right;
} .zd-imgChange-img {
z-index:;
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:;
z-index: -1;
}
.zd-imgChange-img-item-temp{
z-index:;
}
.zd-imgChange-img-item-sel {
z-index:;
} .zd-imgChange-controll {
z-index:;
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:;
} .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);
}

CSS代码部分

HTML

 <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width">
<title>图片切换</title>
<script src="jquery-1.10.2.min.js"></script>
<link href="zoeDylan.ImgChange.css" rel="stylesheet" />
<script src="zoeDylan.ImgChange.js"></script>
<script>
var a_imgs = new Array(//插入图片地址
'./1 (1).jpg',
'./1 (2).jpg',
'./1 (3).jpg',
'./1 (4).jpg'
),
a_links = new Array(//点击图片跳转的网址
'www.baidu.com',
'www.qq.com',
'www.google.com',
'www.zol.com'
),
a_tips = new Array(//鼠标停靠的提示
'百度',
'腾讯',
'谷歌',
'中关村'
);
$(function () {
$('#imgc').zoeDylan_ImageChange({//设置
width: 500,
height: 300,
imgs: a_imgs,
links: a_links,
tips: a_tips,
timers:2000
});
});
</script>
</head>
<body>
<div id="imgc">
<!-- <span class="zd-imgChange-change zd-imgChange-change-left"><</span>
<div class="zd-imgChange-img">
<img class="zd-imgChange-img-item" src="http://subject.9ria.com/html5game/images/t1f.jpg" alt="图片加载错误!" title="提示" />
</div>
<div class="zd-imgChange-controll"><span>d</></div>
<span class="zd-imgChange-change zd-imgChange-change-right">></span>-->
</div>
</body>
</html>

HTML代码部分

ps:由于夜深了,所以没详细说明,有时间补上,下载插件压缩包可以很轻松查看里面的说明,尽量使用高版本浏览器,目测测试浏览器:IE11 IE10 IE6 google 猎豹 欧鹏 可以完美运行,IE6透明效果有损失

zoeDylan.ImgChange 图片切换插件的更多相关文章

  1. 推荐几款jquery图片切换插件

    一.前言 毕业季到了,大家都在匆匆忙忙的记录大学里最美好的时光,照片中各种花式.各种姿势都涌现出来了.这么多的照片怎么展示出来给自己的好友看呢?有人选择做成视频,有人选择ps之后做成图片集,而我选择利 ...

  2. jQuery图片切换插件jquery.cycle.js

    Cycle是一个很棒的jQuery图片切换插件,提供了非常好的功能来帮助大家更简单的使用插件的幻灯功能 下载cycle插件并引入,此时,注意把引入它的代码放在引入jQuery主文件之后. <he ...

  3. 手机触屏滑动图片切换插件swiper.js

    今天给大家分享一款手机触屏滑动图片切换插件swiper.js是一款swiper手机触屏滑动图片幻灯片,适合各种尺寸.效果图如下: 在线预览   源码下载 实现的代码. html代码: <div ...

  4. Javascript:一款简易的图片切换插件

    最近迷上javascript,每天不写点什么都不舒服哈~ 尽管自己能力有限,还是尽自己所能写点东西出来. 实现效果: 效果预览:http://codepen.io/anon/pen/BNjxXj 该插 ...

  5. jquery图片切换插件jquery.cycle.js参数详解

    转自:国人的力量 blog.163.com/xz551@126/blog/static/821257972012101541835491/ 自从使用了jquery.cycle.js,我觉得再也不用自己 ...

  6. jQuery实现多种切换效果的图片切换的五款插件

    1:Nivo SliderNivoslider:丰富的图片切换效果 官方网址:https://themeisle.com/plugins/nivo-slider 查看演示:https://www.he ...

  7. 20+功能强大的jQuery/CSS3图片特效插件

    以下是分享的20几个不错的图片特效插件,基于jQuery和CSS3. 1.jQuery图片下滑切换播放效果 这是一款基于jQuery的焦点图插件,这款焦点图的特点是有向下滑动的动画效果,滑到底部时,有 ...

  8. 30款jQuery常用网页焦点图banner图片切换 下载

    1.jquery 图片滚动特效制作 slide 图片类似窗帘式图片滚动 查看演示 2.jquery幻灯片插件带滚动条的圆形立体图片旋转滚动 查看演示 3.jQuery图片层叠旋转类似洗牌翻转图片幻灯片 ...

  9. 18款 非常实用 jquery幻灯片图片切换

    1.jquery图片滚动仿QQ商城带左右按钮控制焦点图片切换滚动 jquery图片特效制作仿腾讯QQ商城首页banner焦点图片轮播切换效果,带索引按钮控制和左右按钮控制图片切换. 查看演示>& ...

随机推荐

  1. C# Ftp文件处理

    1.创建文件夹 /// <summary> /// ftp创建文件夹(只能创建单层目录) /// </summary> /// <param name="Uri ...

  2. 数据库相关 sql 语句

    1.操作某数据库 use 数据库名称,然后可以操作该数据库下的某张表 2.$res=mysql_query($sql); 该语句如果用在封装的函数体里,则不用传入第二个参数$conn来指定连接,这样才 ...

  3. SiteMesh, SpringMVC, Shiro 配置

    1. 首先在在web.xml文件中,加入SiteMesh和shiro的过滤器,保证SiteMesh的过滤器配置放在shiro的过滤器后面,不然的话,shiro的标签不能正确处理. <?xml v ...

  4. 读书笔记——OpenGL超级宝典

    对于某些函数的理解 glClear和glClearColor glClearColor指定glClear清除特定缓冲区时使用的值. glFlush 让所有已发送的命令尽快的由实际的绘制引擎执行. gl ...

  5. 常用HTML正则

    <?php //HTML a连接正则 $str = ''; $isMatched = preg_match('/<a.*?[^<]>.*?<\/a>/', $str ...

  6. 烂泥:LVM学习之KVM利用LVM快照备份与恢复虚拟机

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 最近一段时间一直在学习有关LVM逻辑卷方面的知识,前几篇文章介绍了有关LVM的逻辑卷的基本相关知识,包括逻辑卷及卷组的扩容与缩小.今天我们再来介绍LVM ...

  7. Sublime Text 2 (for OS X )配置成可以运行基于python3解释器的 .py文件

    Mac自带的python 其version是python 2.7 官网下的Sublime Text 2部署好了以后默认也是 为了使ST2 可以在command+B时可以运行基于python3的.py, ...

  8. C++ new(2)

    1. new与operator new C++中有很多语法让人难以理解,如:new operator(操作符,下同)和operator new之间差异,确切的说,应该是new与operator new ...

  9. Helloworld -SilverN

    /*Hello World*/ #include<iostream> #include<cstdio> #include<cstring> using namesp ...

  10. selenium循环点击文本框

    1.可以用xpath循环点击checkbox List<WebElement> list = dr.findElements(By.className("datagrid-row ...