runxinzhi.com
首页
百度搜索
单张图片轮换
单独图片轮换,点击左右按钮,实现翻页效果。
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>单独图片轮换 - 豪情</title> <style type="text/css"> *{margin:0;padding:0;} body{font:12px/1.125 Arial,Helvetica,sans-serif;background:#000;} table{border-collapse:collapse;border-spacing:0;} li{list-style:none;} fieldset,img{border:0;} article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block} a:focus,input,textarea{outline-style:none;} textarea{resize:none} a{color:#0a8cd2;text-decoration:none;} a:hover{color:#f60;text-decoration:underline;} .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;} .clearfix{display:inline-block;} .clearfix{display:block;} .none{display:none} .demo{180px;height:210px;margin:40px auto;background:#fff;padding:25px;border:2px solid #ccc;border-radius:5px;} .scrollBox{display:inline;float:left;height:223px;position:relative;180px;overflow:hidden;} .prev,.next{background:url(//images0.cnblogs.com/blog/100150/201305/01234427-d9c492e118d040ffb59ec9d80955edbb.png) 0 0 no-repeat;} .prev{background-position:0 0;bottom:7px;cursor:pointer;display:inline-block;height:13px;position:absolute;right:20px;15px;z-index:99;} .next{background-position:-22px 0;bottom:7px;cursor:pointer;display:inline-block;height:13px;position:absolute;right:0;15px;z-index:99;} .control{display:inline;float:left;margin:0 auto;180px;} .control div{float:left;} #control_scroll{height:223px;overflow:hidden;position:relative;180px;} .pic{position:absolute;float:left;} .pic li{display:inline;float:left;text-align:left;180px;} .pic li img.lbimg{height:190px;margin:0 auto 12px;overflow:hidden;180px;} </style> </head> <body> <!--http://sports.qq.com/photo/?pgv_ref=aio2012&ptlang=2052--> <!--http://news.qq.com/base2011/ued_scroll.js--> <div class="demo"> <div class="scrollBox"> <div id="prev" class="prev"></div> <div class="control" id="container"> <ul class="pic"> <li><a href="#"><img class="lbimg" alt="张蓝心登杂志秀美腿" src="http://img1.gtimg.com/sports/pics/hv1/235/122/1287/83718520.jpg" /><br /> 张蓝心登杂志秀美腿</a> </li> <li><a href="#"><img class="lbimg" alt="潘晓婷蕾丝装身姿动人" src="http://img1.gtimg.com/sports/pics/hv1/242/122/1287/83718527.jpg" /><br /> 潘晓婷蕾丝装身姿动人</a> </li> <li><a href="#"><img class="lbimg" alt="泛珠赛车宝贝清丽登场" src="http://img1.gtimg.com/sports/pics/hv1/249/122/1287/83718534.jpg" /><br /> 泛珠赛车宝贝清丽登场</a> </li> <li><a href="#"><img class="lbimg" alt="CBA宝贝热舞助阵" src="http://img1.gtimg.com/sports/pics/hv1/24/188/1286/83670114.jpg" /><br /> CBA宝贝热舞助阵</a> </li> <li><a href="#"><img class="lbimg" alt="徐冬冬写真姿态优雅" src="http://img1.gtimg.com/sports/pics/hv1/237/122/1287/83718522.jpg" /><br /> 徐冬冬写真姿态优雅</a> </li> </ul> </div> <div id="next" class="next"></div> </div> </div> <script type="text/javascript"> (function(window){ function id(node){ return typeof node == 'string' ? document.getElementById(node) : node; } function SingleSlide(obj){ for(var p in obj){ this[p] = id(obj[p]); } this.init.apply(this, arguments); } SingleSlide.prototype = { init : function(){ var that = this, timer = null; this.oUl = this.container.getElementsByTagName('ul')[0]; this.aLi = this.oUl.getElementsByTagName('li'); this.iMaxWidth = this.aLi[0].offsetWidth; this.iNow = 0; // 当前标记 var bigBox = this.container.parentNode; this.oUl.innerHTML += this.oUl.innerHTML; this.oUl.style.width = this.aLi[0].offsetWidth * this.aLi.length + 'px'; timer = setInterval(function(){ that.auto(that, that.oUl); }, 2000); this.prevBtn.onclick = function(){ that.prev(that, that.oUl); } this.nextBtn.onclick = function(){ that.auto(that, that.oUl); } bigBox.onmouseover = function(){ clearInterval(timer); } bigBox.onmouseout = function(){ timer = setInterval(function(){ that.auto(that, that.oUl); }, 2000); } }, auto : function(obj, ul){ obj.iNow++; if(obj.iNow >= obj.aLi.length){ obj.iNow = 0; } obj.move(ul, -obj.iNow * obj.iMaxWidth); }, prev : function(obj, ul){ obj.iNow--; if(obj.iNow <= -1){ obj.iNow = obj.aLi.length - 1; } obj.move(ul, -obj.iNow * obj.iMaxWidth); }, move : function(obj, end){ var that = this, iSpeed = 0; clearInterval(obj.timer); obj.timer = setInterval(function(){ iSpeed = (end - obj.offsetLeft) / 5; iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed); obj.style.left = obj.offsetLeft + iSpeed + 'px'; }, 30); } } new SingleSlide({ container : 'container', prevBtn : 'prev', nextBtn : 'next' }); }(window)); </script> </body> </html>
运行代码
相关阅读:
php数组gbk和utf8的相互转化
【原创】SSRS (SQL Serve Reporting Service) 访问权限的问题
【原创】软件开发项目管理总结
【原创】Team Foundation Server 域环境迁移
【转载】 C#中数组、ArrayList和List三者的区别
【转载】NuGet镜像上线试运行
【原创】 关于全局静态变量初始化
【转载】Fiddler进行模拟Post提交json数据,总为null解决方式
【转载】解决Windows 10 局域网内共享的问题
【原创】 查看端口号被占用
原文地址:https://www.cnblogs.com/jikey/p/3053902.html
最新文章
Jqurey学习笔记---1、jqurey简介
SqlHelper
linux 安装nginx
PHP 发送与接收流文件
PHP 调试
PHP Html5上传大文件
单点登录原理
js 常用函数
js 轮播图代码
js 网站顶部导航栏
热门文章
js 网站顶部通用导航
php中switch与ifelse的效率分析
js拼接php拼接
mysql 复制表结构和数据
MYSQL 连接数据库命令收藏
php下载各种编辑器输出的内容到word中展示
谈谈大型分布式网站架构技术总结
php中&&和and有什么区别
$_FILES上传错误类型
rewrite
Copyright © 2020-2023
润新知