demo01.html
复制代码 代码如下:
<!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>手动滚动图片</title>
<style type="text/css">
ul,li{margin:0;padding:0}
img{border:0px;}
#container{padding:40px;}
#showArea img{width:700px;}
a{text-decoration:none;border:0px;}
#scrollDiv{border:#ccc 1px solid;}
#scrollDiv li{background:#A83;}
</style>
<script src="../jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="imgfocus-0.1.0.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$.imgfocus({
objId:"scrollDiv",
showTitle: true,
height:210,
width:280,
speed:1000
});
});
</script>
</head>
<body>
<div id="container">
<div id="scrollDiv">
<ul>
<li><a href="#"><img src="images/1.jpg" alt="images/1.jpg" width="280"/></a></li>
<li><a href="#"><img src="images/2.jpg" alt="images/2.jpg" width="280"/></a></li>
<li><a href="#"><img src="images/3.jpg" alt="images/3.jpg" width="280"/></a></li>
<li><a href="#"><img src="images/4.jpg" alt="images/4.jpg" width="280"/></a></li>
<li><a href="#"><img src="images/5.jpg" alt="images/5.jpg" width="280"/></a></li>
<li><a href="#"><img src="images/6.jpg" alt="images/6.jpg" width="280"/></a></li>
</ul>
</div>
</div>
</body>
</html>
imgfocus-0.1.0.js
复制代码 代码如下:
/**
* 手动滚动图片
*
**/
$.extend({
imgfocus: function(opt, callback) {
//alert("suc");
this.defaults = {
// 滚动区域id
objId: "",
// 是否在大图下方显示标题
showTitle: false,
// 每行的宽度
width: 300,
// div的高度
height: 100,
// 每次滚动的行数
line: 1,
// 自动滚动的行数
autoLine: 1,
// 动作时间
speed: 0,
// 滚动间隔
interval: 3000,
// 图片根目录
imgPath: "",
// 间隔句柄,不需要设置,只是作为标识使用
picTimer: 0,
// 按钮透明度
opacity: 0.3
};
//参数初始化
var opts = $.extend(this.defaults, opt);
// 定义外层元素样式
$("#" + opts.objId).css({
"position": "relative",
"overflow": "hidden",
"width": (opts.line * opts.width) + "px"
});
// 定义ul样式
$("#" + opts.objId + " ul").css({
"width": opts.width * $("#" + opts.objId + " ul").find("li").size() + "px",
"height": opts.height + "px"
});
// 定义li样式
$("#" + opts.objId + " ul li").css({
"display": "block",
"float": "left",
"width": opts.width + "px",
"height": opts.height + "px"
});
// 定义img样式
$("#" + opts.objId + " ul li img:first").css({
"display": "block",
"float": "left",
"width": opts.width + "px",
"height": opts.height + "px"
});
if (opts.showTitle) {
$("#" + opts.objId).append("<div id=\"imgfocus_banner\" />");
$("#imgfocus_banner").css({
"width": opts.width + "px",
"height": "20px",
"background": "#333",
"position": "absolute",
opacity: 0.7,
"text-align": "center",
"color": "#FFF",
"left": "0px",
"top": (opts.height - 20) + "px"
});
$("#imgfocus_banner").html("<div id=\"imgfocus_banner_title\" />");
$("#imgfocus_banner_title").text("text");
$("#imgfocus_banner_title").css({
"display": "block",
"float": "left",
"width": (opts.width - 20 * $("#" + opts.objId + " ul li").size()) + "px",
"height": "20px"
});
$("#" + opts.objId + " ul li").each(function(index) {
$(this).attr("index", index);
$("#imgfocus_banner").append("<div id=\"imgfocus_banner_squ" + index + "\" class=\"imgfocus_banner_squ\" >" + (index + 1) + "</div>");
var bgColor;
$("#imgfocus_banner_squ" + index).mouseover(function() {
bgColor = $(this).css("background");
$(this).css({
"background": "#CC0"
});
}).mouseleave(function() {
$(this).css({
"background": bgColor
});
});
// 数字块点击事件
$("#imgfocus_banner_squ" + index).click(function() {
var length = $("#" + opts.objId + " ul li[index=" + index + "]").prevAll().size();
var scrollWidth = 0 - length * opts.width - (0 - $("#" + opts.objId).find("ul:first").css("margin-left").replace("px", ""));
$("#" + opts.objId).find("ul:first").animate({
marginLeft: scrollWidth
},
6,
function() {
for (i = 1; i <= length; i++) {
$("#" + opts.objId).find("li:first").appendTo($("#" + opts.objId).find("ul:first"));
}
$("#" + opts.objId).find("ul:first").css({
marginLeft: 0
});
var index = $("#" + opts.objId).find("li:first").attr("index");
// 数字标签全部变灰色
$(".imgfocus_banner_squ").css({
"background": "#CCC"
});
// 活动的数字标签变红色
$("#imgfocus_banner_squ" + index).css({
"background": "#C00"
});
bgColor = "background:#C00";
changeTitle();
});
});
});
// 数字块样式
$(".imgfocus_banner_squ").css({
"display": "block",
"float": "left",
"margin": "1px",
"width": "18px",
"height": "18px",
"color": "#000",
"background": "#CCC"
});
// 第一个数字块样式
$(".imgfocus_banner_squ:first").css({
"background": "#C00"
});
}
/**
* 自动横向滚动
*/
function scrollLeft() {
var scrollWidth = 0 - opts.autoLine * opts.width - (0 - $("#" + opts.objId).find("ul:first").css("margin-left").replace("px", ""));
$("#" + opts.objId).find("ul:first").animate({
marginLeft: scrollWidth
},
opts.speed,
function() {
for (i = 1; i <= opts.autoLine; i++) {
$("#" + opts.objId).find("li:first").appendTo($("#" + opts.objId).find("ul:first"));
}
$("#" + opts.objId).find("ul:first").css({
marginLeft: 0
});
var index = $("#" + opts.objId).find("li:first").attr("index");
changeTitle();
// 数字标签全部变灰色
$(".imgfocus_banner_squ").css({
"background": "#CCC"
});
// 活动的数字标签变红色
$("#imgfocus_banner_squ" + index).css({
"background": "#C00"
});
});
};
/**
* 切换标题
*/
function changeTitle(){
$("#imgfocus_banner_title").text($("#" + opts.objId).find("li:first img:first").attr("alt"));
}
/**
* 鼠标滑上后显示按钮
*/
$("#" + opts.objId).hover(function() {
$("#button_left").css({
opacity: 1
});
$("#button_right").css({
opacity: 1
});
},
function() {
$("#button_left").css({
opacity: opts.opacity
});
$("#button_right").css({
opacity: opts.opacity
});
}).trigger("mouseleave");
/**
* 最先执行的函数
* 鼠标滑上焦点图时停止自动播放,滑出时开始自动播放
*/
// 初始化标题
changeTitle();
$("#" + opts.objId).hover(function() {
clearInterval(opts.picTimer);
},
function() {
opts.picTimer = setInterval(function() {
scrollLeft();
},
opts.interval); // 自动播放的间隔,单位:毫秒
}).trigger("mouseleave");
}
});
相关推荐:
SEO优化如何提升网站排名,驾驭搜索引擎流量,三亚网站推广方法
AI自动化:开启智能未来的无限可能,simplify ai
怎么分辨文章是不是AI写的?五大技巧揭开真相
SEO适合-提升网站排名的关键策略,张家口品牌推广营销中心
ChatGPT目前,我无法查看或打开附件,但我依然能为你提供全面的帮助,苹果ai谷歌ai
seo规范是什么,seo行业标准 ,啊龙ai音乐
AI优化文章:如何利用人工智能提升写作效率和质量
怎么降低文章的AI生成率:打造更真实、更有价值的内容
ChatGPT当前不可用?背后的原因与解决方案全解析,ai propos
2025年整站SEO排名优化策略:让你的网站脱颖而出,id排版ai
360刷排名工具选哪家?揭秘2025年最强排名优化工具!,ai写作网站哪个好一点
亚马逊的seo是什么阿,亚马逊seo项目 ,中考用ai写作会判0分吗
ChatGPT维护页面-背后的技术与用户体验,ai领域ppt
seo网络培训是什么,seo工作培训会培训啥 ,ai长投影字
软件AI:颠覆未来的智能革命
如何识别文章是否由AI撰写?揭开智能写作的秘密
SEO妍:搜索引擎优化的艺术,轻松打造网络营销新未来,辽宁网站建设贵不贵
seo项目是什么,seo是啥 ,ai ued
SEO抢权:如何在竞争激烈的市场中占得先机,正规网站建设口碑好
ChatGPTWindows版本下载:让AI助力您的工作和生活,ai yamama
ChatGPT无法加载?检查网络并尝试重启,助您快速恢复畅通体验,burj ai
SEO快排还有效果吗揭秘快速排名的真相与未来趋势,ai人像波普
什么是seo伪原创,seo就业前景伪原创怎么写 ,头像ai画怎么弄
揭开“好的AI软件”背后的秘密:让生活和工作更智能的利器
从语言助手到智能生活伙伴,未来的智能助手如何改变我们的生活,网站建设分站公司
UCMS:引领智慧医疗新时代,打造数字化健康未来,推广工作谈营销
SEO很多,如何在竞争激烈的市场中脱颖而出?,在SEO优化中
SEO无限:如何利用SEO技术实现网站流量爆发?,网站建设总监
seo重点工作是什么,seo重点工作是什么意思 ,棋谱检查ai
“曝光量扩大,助力品牌腾飞的秘密武器”,盐山网站优化免费咨询
seo需要什么能力,seo需要哪些技术 ,ai长条弯曲
seO经理是什么岗位,seo经理招聘 ,ai写作重复被查
AI自动生成:开启智能时代的无限可能,ai熊熊图片
seo要会些什么,seo需要学些什么内容 ,轻盈ai
ChatGPT进不去怎么办?解决方案与技巧,轻松畅享智能对话,ai va
为什么“360收录”是你网站推广的必备利器,seo亚马逊
AI网页设计生成-智能化创造无限可能,ai机甲风背景音乐
SEO找出网站流量提升的终极策略,带你走向搜索引擎巅峰!,朝阳模板网站建设价格
SEO策划:让你的网站迅速脱颖而出的秘诀,seo优化和技巧
ChatGPT安装包Windows版:让AI助力你的工作与生活,人工智能ai不是梦在线
seo简报什么意思,seo工作汇报 ,万花筒 ai
seo相当于什么职业,seo相当于什么职业类别 ,usatisfy ai
SEO注意事项:助力网站流量提升的关键策略,济宁快速seo优化价格
AI免费写文章:让创作变得轻松高效
SEO热词:提升网站排名的关键秘诀,一句话营销推广怎么写好
AI文章精简-高效提炼与优化你的内容创作,ai quid
AI生成网页模板,轻松打造专业网站,ai网格画法
SEO关键词利器:如何借助精准关键词提升网站流量与排名,ai绘画客户
OpenAI智能诊断医疗-开启精准医疗新纪元,跟侯维静学ai
SEO全站优化:打造强大网站排名的必备利器,AI论文写作的优点