码迷,mamicode.com
首页 > 其他好文 > 详细

3秒一换轮播(鼠标选中旋转停止定时) 动画案例

时间:2017-09-17 16:35:07      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:get   广告轮播   nload   padding   轮播图片   span   ++   ansi   top   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>广告轮播</title>
    <script type="text/javascript" src="tzy.js" language="JavaScript"></script>
    <link rel="stylesheet" href="tzy.css" type="text/css">
</head>
<body onload="lunbozantin()">
<div>
    <p><b>我是轮播图片</b></p>
    <img src="1.jpg" alt="lol图片" id="tupian" onMouseOver="stoplunbo()" onMouseOut="lunbozantin()">
</div>
</body>
</html>
*{
    margin:0px;
    padding:0px;
}
div{
    width: 508px;
    height: 330px;
    margin: 100px auto;
    padding: 5px;
    background-color: coral;
}
p{
    width: 528px;
    height: 30px;
    text-align: center;
    font-family: "楷体";
    line-height: 30px;
    font-size: 25px;
}
img{
    width: auto;
    height: auto;
    background-color: deepskyblue;
    -webkit-transition: width 1s, height 1s, -webkit-transform 1s;
    /*暂定高宽无变化自动,有变化则为1秒*/
    transition: width 1s, height 1s, transform 1s;
}
img:hover{
    width: auto;
    height: auto;
    transform:rotate(360deg);
    -webkit-transform:rotate(360deg);
}
var arr = new Array("1.jpg","2.jpg","3.jpg","4.jpg");
var count = 1;
var b;
function lunbo() {
    a = document.getElementById("tupian");
    a.src =arr[count];
    count++;
    if(count==4){
        count=0;
    }
}
function stoplunbo(){
    clearInterval(b);
}function lunbozantin() {
    b = setInterval(lunbo,3000);
}

 

3秒一换轮播(鼠标选中旋转停止定时) 动画案例

标签:get   广告轮播   nload   padding   轮播图片   span   ++   ansi   top   

原文地址:http://www.cnblogs.com/ttzzyy/p/7535867.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!