商城常用滚动的焦点图效果代码简单实用 - Web前端
作者:98wpeu发布时间:2026-06-02分类:网页前端技术浏览:131
导读:这种商城的效果网上很多,但大多是插件,要么JS写的太过于复杂,对于学习的童鞋来说看起来比较费劲,这个看起来比较简单,也比较容易理解,各位童鞋需要的请围观,也欢迎各位评价,贴代码(为...
这种商城的效果网上很多,但大多是插件,要么JS写的太过于复杂,对于学习的童鞋来说看起来比较费劲,这个看起来比较简单,也比较容易理解,各位童鞋需要的请围观,也欢迎各位评价,贴代码(为方便使用,代码复制即可用,无需另外添加东西):
复制代码 代码如下:
<!doctypehtml>
<HTML lang="en">
<head>
<title>商城常用滚动的效果,简单实用</title>
<script type="text/javascript" src="http://jt.875.cn/js/JQuery.js"></script>
<script type="text/JavaScript">
$(function(){
var len = $(".num > li").length;
var index = 0;
var adtimer;
$(".num li").mouSEOver(function(){
index = $(".num li").index(this);
showImg(index);
}).eq(0).mouseover();
//滑入 停止动画,滑出开始动画.
$('.ad').hover(function(){
clearinterval(adTimer);
},function(){
adTimer = SetInterval(function(){
showImg(index)
index++;
if(index==len){index=0;}
} , 3000);
}).trigger("mouseleave");
})
// 通过控制top ,来显示不同的幻灯片
function showImg(index){
var adheight = $(".content .ad").height();
$(".slider").stop(true,false).Animate({top : -adHeight*index},1000);
$(".num li").removeclass("on")
.eq(index).addClass("on");
}
</script>
<style type="text/CSS">
ul,li{ margin:0;padding:0;}
.ad { margin-bottom:10px;width:586px; height:150px; overflow:hidden;position:relative;}
.content .slider,.content .num{position:absolute;}
.content .slider li{list-style:none;display:inline;}
.content .slider img{ width:586px; height:150px;display:block;}
.content .num{ right:5px; bottom:5px;}
.content .num li{float: left;color: #FF7300;text-align: center; line-height: 16px;width: 16px;height: 16px;font-family: Arial; font-size: 12px;cursor: pointer;overflow: hidden;margin: 3px 1px;border: 1px solid #FF7300;background-color: #fff;
}
.content .num li.on{color: #fff;line-height: 21px;width: 21px;height: 21px; font-size: 16px;margin: 0 1px;border: 0;background-color: #FF7300;font-weight: bold;}
</style>
</head>
<body>
<div class="content">
<div class="ad" >
<ul class="slider" >
<li><img src="HTTP://pic.875.cn/upload/2013-03-26/1504517406.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-01-24/1634016671.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-03-07/1506174974.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-03-26/1504517406.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-01-24/1634016671.jpg" width="586" height="150"/></li>
</ul>
<ul class="num" >
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</div>
</body>
</html>
效果图如下:
复制代码 代码如下:
<!doctypehtml>
<HTML lang="en">
<head>
<title>商城常用滚动的效果,简单实用</title>
<script type="text/javascript" src="http://jt.875.cn/js/JQuery.js"></script>
<script type="text/JavaScript">
$(function(){
var len = $(".num > li").length;
var index = 0;
var adtimer;
$(".num li").mouSEOver(function(){
index = $(".num li").index(this);
showImg(index);
}).eq(0).mouseover();
//滑入 停止动画,滑出开始动画.
$('.ad').hover(function(){
clearinterval(adTimer);
},function(){
adTimer = SetInterval(function(){
showImg(index)
index++;
if(index==len){index=0;}
} , 3000);
}).trigger("mouseleave");
})
// 通过控制top ,来显示不同的幻灯片
function showImg(index){
var adheight = $(".content .ad").height();
$(".slider").stop(true,false).Animate({top : -adHeight*index},1000);
$(".num li").removeclass("on")
.eq(index).addClass("on");
}
</script>
<style type="text/CSS">
ul,li{ margin:0;padding:0;}
.ad { margin-bottom:10px;width:586px; height:150px; overflow:hidden;position:relative;}
.content .slider,.content .num{position:absolute;}
.content .slider li{list-style:none;display:inline;}
.content .slider img{ width:586px; height:150px;display:block;}
.content .num{ right:5px; bottom:5px;}
.content .num li{float: left;color: #FF7300;text-align: center; line-height: 16px;width: 16px;height: 16px;font-family: Arial; font-size: 12px;cursor: pointer;overflow: hidden;margin: 3px 1px;border: 1px solid #FF7300;background-color: #fff;
}
.content .num li.on{color: #fff;line-height: 21px;width: 21px;height: 21px; font-size: 16px;margin: 0 1px;border: 0;background-color: #FF7300;font-weight: bold;}
</style>
</head>
<body>
<div class="content">
<div class="ad" >
<ul class="slider" >
<li><img src="HTTP://pic.875.cn/upload/2013-03-26/1504517406.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-01-24/1634016671.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-03-07/1506174974.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-03-26/1504517406.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-01-24/1634016671.jpg" width="586" height="150"/></li>
</ul>
<ul class="num" >
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</div>
</body>
</html>
效果图如下:
相关推荐
- 使用jQuery将多条数据插入模态框的实现代码 - Web前端
- 单元选择合并变色示例代码 - Web前端
- JQuery获取表格数据示例代码 - Web前端
- 简单选项卡 js和jquery制作方法分享 - Web前端
- jquery Ajax 实现加载数据前动画效果的示例代码 - Web前端
- jQuery操作表格(table)的常用方法、技巧汇总 - Web前端
- jquery表单验证框架提供的身份证验证方法(示例代码) - Web前端
- jquery实现图片翻页效果 - Web前端
- jQuery动画效果-slideUp slideDown上下滑动示例代码 - Web前端
- Jquery封装tab自动切换效果的具体实现 - Web前端
- 网页前端技术排行
-
- 1【第六章】Foundation之按钮和下拉功能 - Web前端
- 2jQuery编写widget的一些技巧分享 - Web前端
- 3基于jquery的滚动条滚动固定div(附演示下载) - Web前端
- 4在Mac/PC上远程调试iPhone/iPad上的网页 - Web前端
- 5jQuery实例教程:制作网页中可折叠的面板 - Web前端
- 6分析Iconfont-阿里巴巴矢量常用图标库 - Web前端
- 7JS网页制作实例:标签云 - Web前端
- 8[Web前端]用javascript实现默认图片替代未显示的图片 - Web前端
- 9分享精心挑选的12款优秀jQuery Ajax分页插件和教程 - Web前端
- 最近发表
-
- WordPress随机显示特色图片插件:Random Post Thumbnails
- KeePass实现Chrome浏览器自动填充密码方法一
- LNMP一键包nginx 301强制跳转到https教程
- KeePass实现Chrome浏览器自动填充密码方法二
- #建站# 免费的VPS管理软件Xshell8/Xftp8中文版下载
- 使用Xshell 8连接VPS教程_电脑登录vps的方法
- WordPress评论界面添加烟花????效果
- 不同浏览器书签同步方案:坚果云+Floccus_详细使用教程
- iOS端KeePassXC客户端APP:Strongbox Password Safe
- 给WordPress评论中的Gravatar头像图片添加ALT属性


