zoukankan      html  css  js  c++  java
  • 轮播图

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>妙味课堂-www.miaov.com</title>
    <style>
    body,ul,ol{margin:0;padding:0;}
    li{ list-style:none;}
    img{ border:none; vertical-align:top; }
    #box{470px;height:150px; position:relative; margin:30px auto; overflow:hidden;}
    ul{ 470px; position:absolute;left:0; top:0; z-index:1;}
    ul li{470px; position:absolute; top:0;}
    ol{z-index:2; 120px; position:absolute;right:10px; bottom:10px;}
    ol li{ 20px;height:20px; float:left;margin:0 2px; display:inline; background:#fff; color:#f60; line-height:20px; text-align:center;}
    ol .active{ background:#f60; color:#fff;}
    </style>
    <script src="jquery-1.11.1.js"></script>
    <script>

    $(function(){

    var $oLi = $('ol li');
    var $uLi = $('ul li');
    var iNow = 0;
    var oneWidth = $uLi.width();

    $uLi.slice(1).each(function(){
    $(this).css( 'left', oneWidth );
    });
    var bBtn = true;
    $oLi.mouseover(function(){
    if(bBtn){
    bBtn = false;
    $oLi.attr('class','');

    $(this).attr('class','active');

    var index = $(this).index();

    if(iNow < index){
    $uLi.eq(index).css('left',oneWidth);
    $uLi.eq(iNow).animate({'left':-oneWidth});
    }
    else if(iNow > index){
    $uLi.eq(index).css('left',-oneWidth);
    $uLi.eq(iNow).animate({'left':oneWidth});
    }

    $uLi.eq(index).animate({'left':0},function(){
    bBtn = true;
    });

    iNow = index;
    }
    });

    });
    </script>
    </head>
    <body>
    <div id="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>
  • 相关阅读:
    centos安装rvm报错@curl -L get.rvm.io | bash -s stable fails on cent OS
    linux命令 环境设置 顺序
    mysql-5.7.20基本用法
    gitlab&Jenkins 详细介绍及其应用
    git 详细部署及其应用
    zabbix详细介绍及其自动动态发现
    redis 缓存应用
    Linux下rpm、yum和源码三种安装方式详细介绍
    js中获取时间new date()的用法
    Apache Tomcat/8.5.56 启动命令行中文乱码
  • 原文地址:https://www.cnblogs.com/aomore/p/4598919.html
Copyright © 2011-2022 走看看