轮播图特效
来源:互联网 发布:python 内存地址 编辑:程序博客网 时间:2024/06/05 15:35
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="css/lunbo.css"/>
<script src="js/lunbo.js"></script>
</head>
<body>
<nav id="contenter">
<figure id="imgs" style="left: -600px">
<img src="img/5.jpg" />
<img src="img/1.jpg" />
<img src="img/2.jpg" />
<img src="img/3.jpg" />
<img src="img/4.jpg" />
<img src="img/5.jpg" />
<img src="img/1.jpg" />
</figure>
<header id="botn">
<span class="on"></span>
<span></span>
<span></span>
<span></span>
<span></span>
</header>
<footer >
<a id="botn1"><</a>
<a id="botn2">></a>
</footer>
</nav>
</body>
</html>
*{
margin: 0;
padding:0;
}
nav{
width: 600px;
height: 400px;
position: relative;
margin: 100px auto;
border: 3px solid #000000;
overflow: hidden;
}
figure{
position: absolute;
height: 400px;
z-index: 1;
width: 4200px;
}
figure img{
display: block;
float: left;
}
footer {
position: absolute;
z-index: 2;
width: 600px;
height: 50px;
top: 175px;
left: 0px;
display: none;
}
footer a{
text-align: center;
text-decoration: none;
display: block;
width: 50px;
height: 50px;
background-color: black;
opacity: .2;
color: white;
font-size: 40px;
cursor: pointer;
}
footer a:nth-last-of-type(2){
float: left;
}
footer a:nth-last-of-type(1){
float: right;
}
nav:hover footer{
display: block;
}
footer:hover a{
opacity: .5;
}
header{
position: absolute;
width: 100px;
height: 20px;
top: 370px;
left: 250px;
display: -webkit-box;
-webkit-box-pack: justify;
z-index: 2;
}
header span{
display: block;
height: 10px;
width: 10px;
border-radius: 50%;
border: 1px solid white;
cursor:pointer;
}
.on{
background-color: white;
}
.off{
background-color: none;
}
window.onload = function() {
var contenter=document.getElementById("contenter")
var imgs = document.getElementById("imgs");
var botns = document.getElementById("botn").getElementsByTagName("span");
var botn1 = document.getElementById("botn1");
var botn2 = document.getElementById("botn2");
var index = 1;
var timer;
function showBotton() {
for (var i = 0; i < botns.length; i++) {
botns[i].className = "";
}
botns[index - 1].className = "on";
}
// 动画播放函数
function anmiate(offset) {
var times = 300;
var onec = 10;
var speed = offset / (times / onec);
var newleft = parseInt(imgs.style.left) + offset;
var go = function() {
if ((speed < 0 && newleft < parseInt(imgs.style.left)) || (speed > 0 && newleft > parseInt(imgs.style.left))) {
imgs.style.left= parseInt(imgs.style.left)+speed+"px" ;
setTimeout(go,onec);
} else {
imgs.style.left = newleft+ "px";
if (parseInt(imgs.style.left) > -600) {
imgs.style.left = "-3000px";
}
if (parseInt(imgs.style.left) < -3000) {
imgs.style.left = "-600px";
}
}
}
go();
}
// 动画播放函数
botn1.onclick = function() {
if (index == 1) {
index = 5;
} else {
index -= 1;
}
showBotton();
anmiate(600);
}
botn2.onclick = function() {
if (index == 5) {
index = 1;
} else {
index += 1;
}
showBotton();
anmiate(-600);
}
for (var i = 0; i < botns.length; i++) {
(function(i) {
botns[i].onclick = function() {
if (this.className == "on") {
return;
}
var offset = -600 * (i - index+1);
anmiate(offset);
index = i + 1;
showBotton();
}
})(i);
}
function play () {
timer=setInterval(botn2.onclick,3000)
}
function stop (){
clearInterval(timer);
}
play ();
contenter.onmouseover=function () {
stop ();
}
contenter.onmouseout=function () {
play ();
}
};
0 0
- 轮播图特效
- 轮播图特效
- 特效
- 特效
- 特效
- 特效
- 特效
- 特效
- 特效
- 特效
- JQ动画和特效轮播图
- 【特效】挺不错的一个轮播图
- jQuery插件slides实现无缝轮播图特效
- js特效-无缝轮播图,简单上手
- SVG特效&canvas特效
- Android特效-视差特效
- JS特效(鼠标特效)
- 仿照(小米官网首页轮播图)特效js代码
- 滑动门效果 (函数立即调用的试用方法)(使用计时器延时执行)
- linux基本权限
- 判断一个数是否是素数。。
- iOS中的NSURLProtocol
- ElasticSearch简单查询
- 轮播图特效
- java嵌套类(Nested Classes)总结
- java几行代码搞定算术表达式的计算
- 返回顶部特效(立即中断)
- javascript - 常用互动 innerhtml className display class
- 1+1<<1+1优先级
- jquery事件委托
- 第11周OJ实践 循环画三角形
- 深入理解观察者模式(一)