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

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>轮播</title>
    <style>
    *{
    margin:0;
    padding: 0;
    }
    .banner_wrap{
    780px;
    height: 231px;
    overflow: hidden;
    position: relative;
    margin: 0 auto;
    }
    .banner{
    5460px;
    height: 231px;
    list-style: none;
    margin-left: -780px;
    }
    .banner li{
    float: left;
    780px;
    height: 231px;
    }
    .prev{
    left:0;
    border-top-left-radius: 50%;
    border-bottom-left-radius: 50%;
    }
    .next{
    right:0;
    border-top-right-radius: 50%;
    border-bottom-right-radius: 50%;
    }
    .arrows{
    position: absolute;
    margin-top: -35px;
    background: rgba(205,205,205,0.6);
    35px;
    height:70px;
    top:50%;
    font-size: 18px;
    color: #fff;
    text-align: center;
    line-height: 70px;
    cursor: pointer;
    }
    .round_wrap{
    125px;
    position: absolute;
    bottom: 20px;
    left:50%;
    margin-left: -62px;
    list-style: none;
    cursor: pointer;
    }
    .round_wrap li{
    15px;
    height: 15px;
    border-radius: 50%;
    background: rgba(230,230,230,0.7);
    float: left;
    margin-left: 10px;
    }
    .round_wrap li.now{
    background: rgba(50,50,50,0.9);
    }
    </style>
    <script src="js/jquery-1.12.4.min.js"></script>
    <script>
    $(function () {
    $('.banner_wrap').hover(function () {
    $('.arrows').css('background',' rgba(205,205,205,0.9)');
    clearInterval(repeat)
    },function () {
    $('.arrows').css('background',' rgba(205,205,205,0.6)');
    repeat = setInterval(function () {
    if($('.banner:not(:animated)').length>0) {
    scrollIndex++;
    scrollMove()
    }
    },2000);
    });
    var prev=$('.prev'),
    next=$('.next'),
    banner=$('.banner'),
    scrollIndex=1,
    elWidth = 780;
    next.click(function () {
    if($('.banner').not(":animated").length>0) {
    scrollIndex++;
    scrollMove()
    }
    });
    prev.click(function () {
    if($('.banner:not(:animated)').length>0) {
    scrollIndex++;
    scrollMove()
    }
    });
    function scrollMove() {
    banner.animate({
    'marginLeft':-scrollIndex*elWidth+'px'
    },500,function () {
    if(scrollIndex==6){
    scrollIndex=1;
    banner.css('margin-left',-elWidth+'px');
    }
    if(scrollIndex==0){
    scrollIndex=5;
    banner.css('margin-left','-3900px');
    }
    $('.round_wrap li').eq(scrollIndex-1).addClass('now').siblings().removeClass('now')
    });
    }
    var repeat = setInterval(function () {
    if($('.banner:not(:animated)').length>0) {
    scrollIndex++;
    scrollMove()
    }
    },2000);
    $('.round_wrap li').click(function () {
    scrollIndex = $(this).index()+1;
    scrollMove()
    })
    })
    </script>
    </head>
    <body>
    <div class="banner_wrap">
    <div class="prev arrows">&lt;</div>
    <div class="next arrows">&gt;</div>
    <ul class="banner">
    <li><img src="imasges/article_image09.jpg"/></li>
    <li><img src="imasges/article_image05.jpg"/></li>
    <li><img src="imasges/article_image06.jpg"/></li>
    <li><img src="imasges/article_image07.jpg"/></li>
    <li><img src="imasges/article_image08.jpg"/></li>
    <li><img src="imasges/article_image09.jpg"/></li>
    <li><img src="imasges/article_image05.jpg"/></li>
    </ul>
    <ul class="round_wrap">
    <li class="now"></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    </ul>
    </div>
    </body>
    </html>
  • 相关阅读:
    第二章 怎样培养好习惯
    十六、使用jQuery操作元素 —— DOM属性与HTML元素属性
    第六章 培养感恩的习惯
    js 问题集锦 之 二
    HTML 5 学习笔记之 常用标签简介
    MySql 笔记一 之 时间和日期函数
    HTML 5 学习笔记之 canvas 标签
    MySql 笔记三 循环语句
    转载文:架构经验系列文章
    MySql 笔记二 基础命令
  • 原文地址:https://www.cnblogs.com/xiaoxiongv1/p/8034655.html
Copyright © 2011-2022 走看看