jq demo 轮播图,图片可调用,向左,自动+鼠标点击切换
![](https://images2015.cnblogs.com/blog/1092086/201706/1092086-20170620175449288-1405583000.png)
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>JQ轮播图,图片可调用,自动向左切换+鼠标点击切换</title>
<script src="jquery-1.11.1.js"></script>
<style>
body,ul,ol,li,img{margin:0;padding:0;}
ul,ol,li{list-style:none;}
img{vertical-align:top;}
#img_box{width:470px;height:150px;margin:30px auto;position:relative;overflow:hidden;}
#img_box ul{position:absolute;top:0;left:0;z-index:1;}
#img_box ul li{width:470px; position:absolute; top:0;}
#img_box ol{position:absolute;bottom:15px;right:15px;z-index:2;}
#img_box ol li{display:inline-block;cursor:pointer;width:20px;height:20px;margin-right:5px;line-height:20px;text-align:center;background:#fff; color:#f60;}
#img_box ol .active{background:#f60; color:#fff;padding:2px;bottom:2px;}
</style>
<script>
$(function(){
var iNow = 0;
var timer = null;
var $uLi=$('#img_box ul li');
var oneWidth=$uLi.width(); if($uLi.length>0){
for(var i = 1; i <= $uLi.length; i++){
var $olLi=$('<li>'+ i +'</li>');
$('#img_box ol').append($olLi);
}
$('#img_box ol li').eq(0).attr('class','active');
};
$uLi.each(function(i,elem){
$(this).css('left',i*oneWidth);
});
timer=setInterval(toRun,2000);
function toRun(){
if($uLi.length>1){
if (iNow==$uLi.length-1){
iNow=0;
}else{
iNow++;
};
$('#img_box ol li').attr('class','');
$('#img_box ol li').eq(iNow).attr('class','active');
$('ul').stop().animate({left : -470 * iNow},1000);
}
};
$('#img_box').mouseover(function(){
clearInterval(timer);
}).mouseout(function(){
timer=setInterval(toRun,2000);
})
$('#img_box ol li').click(function(e){
$('#img_box ol li').attr('class','');
$(this).attr('class','active');
iNow=$(this).index();
$('ul').stop().animate({left : -470 * iNow},1000);
}); });
</script>
</head>
<body>
<div id="img_box">
<ul>
<li><img src="img/1.jpg" alt="" /></li>
<li><img src="img/2.jpg" alt="" /></li>
<li><img src="img/3.jpg" alt="" /></li>
<li><img src="img/4.jpg" alt="" /></li>
<li><img src="img/5.jpg" alt="" /></li>
</ul>
<ol>
<!--<li class="active">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>-->
</ol>
</div>
</body>
</html>
jq demo 轮播图,图片可调用,向左,自动+鼠标点击切换的更多相关文章
- jq demo 轮播图,图片可调用,向上,自动+鼠标点击切换
1 <!doctype html> <html> <head> <meta http-equiv="Content-Type" conte ...
- iview Carousel 轮播图自适应宽高;iview 轮播图 图片重叠问题;iview tabs 高度互相影响问题;vue this问题;
最终效果图: 一.轮播图中图片自适应宽高: <Carousel loop v-bind:height="imgHeight+'px'" v-model="caro ...
- JQ 实现轮播图(3D旋转图片轮播效果)
轮播图效果如下: 代码: <!DOCTYPE html> <html xmlns="/www.w3.org/1999/xhtml"> <head> ...
- JQ万能轮播图
lunbotu.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...
- 5 项目---自定义用户模型以及轮播图图片url返回格式
创建自定义的用户模型类 1. 用命令创建users 应用 2. 将users 注册到settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'd ...
- jq龙禧轮播图
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- JQ无缝轮播图-插件封装
类似京东的这种无缝轮播效果: 实例代码下载 HTML代码: <body> <!-- /*觅me 探索生活*/ --> <div class="test" ...
- 原生js写简单轮播图方式1-从左向右滑动
轮播图就是让图片每隔几秒自动滑动,达到图片轮流播放的效果.轮播图从效果来说有滑动式的也有渐入式的,滑动式的轮播图就是图片从左向右滑入的效果,渐入式的轮播图就是图片根据透明度渐渐显示的效果,这里说的是实 ...
- js - 面向对象 - 小案例:轮播图、随机点名、选项卡、鼠标拖拽
面向对象 对象 : (黑盒子)不了解内部结构, 知道表面的各种操作. 面向对象 : 不了解原理的情况下 会使用功能 . 面向对象是一种通用思想,并非编程中能用,任何事情都能用. 编程语言的面向对象的特 ...
随机推荐
- Go 初体验 - 死锁的几种情况
go 语言里,channel 是一个重要的对象和概念,它是通信的基础实现 如何实例化: ch := make(chan int) 由 channel 通信引起的死锁共有3种: 第一种是因为给 ch 推 ...
- 数据库SQL的分组函数
分组函数:(五个) 1···max(expr):求expr的最大值 }\ 2···min(expr):求expr的最小值 }-- 数据类型是有规定的 3···sum(expr):求expr的总和 }- ...
- Python之猴子补丁
1.在运行时,对属性,方法,函数等进行动态替换 2.其目的往往是为了通过替换,修改来增强,扩展原有代码的能力 #test2.py class Person: def get_score(self): ...
- 【转】jira迁移数据
jira迁移数据有两种方式 方式一: jira系统自带的备份恢复操作 最简单的,但不一定能成功 从/export/atlassian/application-data/jira/export下载至 ...
- 外网访问内网Elasticsearch WEB
外网访问内网Elasticsearch WEB 本地安装了Elasticsearch,只能在局域网内访问其WEB,怎样从外网也能访问本地Elasticsearch? 本文将介绍具体的实现步骤. 1. ...
- Android webview 调起H5微信支付
mWebView.setWebViewClient(new MyWebViewClient()); private class MyWebViewClient extends WebViewClien ...
- 剑指offer(34)第一个只出现一次的字符
题目描述 在一个字符串(1<=字符串长度<=10000,全部由字母组成)中找到第一个只出现一次的字符,并返回它的位置 题目分析 只需要用map记录字符出现的次数就行,比较简单的题 代码 f ...
- 关闭vs的编译警告
现象:出现warning cxxxx.. 解决:项目,属性,C/C++,高级,禁用特定警告,把xxxx输入
- springboot配置cxf
1.引入两个需要的jar <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf- ...
- Lintcode376-Binary Tree Path Sum-Easy
376. Binary Tree Path Sum Given a binary tree, find all paths that sum of the nodes in the path equa ...