当前位置:Web前端 > jquery> 正文

jquery图片轮播代码

时间:2014-7-4类别:Web前端

jquery图片轮播代码

jquery图片轮播代码

一、jquery图片轮播效果图

 

 

二、jquery代码

 

  •  
  • HTML 代码   复制
  • 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional。dtd">
    <html xmlns="http://www.w3。org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>jquery图片滚动仿QQ商城带左右按钮控制焦点图片切换滚动</title>
    <meta name="description" content="jquery图片特效制作仿腾讯QQ商城首页banner焦点图片轮播切换效果,带索引按钮控制和左右按钮控制图片切换。jquery下载。" />
    
    <style type="text/css">
    *{margin:0;padding:0;}
    body{font-size:12px;color:#222;font-family:Verdana,Arial,Helvetica,sans-serif;background:#f0f0f0;}
    .clearfix:after{content: ".";display: block;height: 0;clear: both;visibility: hidden;}
    .clearfix{zoom:1;}
    ul,li{list-style:none;}
    img{border:0;}
    .wrapper{width:800px;margin:0 auto;padding-bottom:50px;}
    h1{height:50px;line-height:50px;font-size:22px;font-weight:normal;font-family:"Microsoft YaHei",SimHei;margin-bottom:20px;}
    /* focus */
    #focus{width:800px;height:280px;overflow:hidden;position:relative;}
    #focus ul{height:380px;position:absolute;}
    #focus ul li{float:left;width:800px;height:280px;overflow:hidden;position:relative;background:#000;}
    #focus ul li li{position:absolute;overflow:hidden;}
    #focus .btnBg{position:absolute;width:800px;height:20px;left:0;bottom:0;background:#000;}
    #focus .btn{position:absolute;width:780px;height:10px;padding:5px 10px;right:0;bottom:0;text-align:right;}
    #focus .btn span{display:inline-block;_display:inline;_zoom:1;width:25px;height:10px;_font-size:0;margin-left:5px;cursor:pointer;background:#fff;}
    #focus .btn span.on{background:#fff;}
    #focus .preNext{width:45px;height:100px;position:absolute;top:90px;background:url(img/sprite.png) no-repeat 0 0;cursor:pointer;}
    #focus .pre{left:0;}
    #focus .next{right:0;background-position:right top;}
    </style>
    
    <script type="text/javascript" src="jquery。js"></script>
    <script type="text/javascript">
    $(function() {
        var sWidth = $("#focus").width(); //获取焦点图的宽度(显示面积)
        var len = $("#focus ul li").length; //获取焦点图个数
        var index = 0;
        var picTimer;
        
        //以下代码添加数字按钮和按钮后的半透明条,还有上一页、下一页两个按钮
        var btn = "<li class='btnBg'></li><li class='btn'>";
        for(var i=0; i < len; i++) {
            btn += "<span></span>";
        }
        btn += "</li><li class='preNext pre'></li><li class='preNext next'></li>";
        $("#focus").append(btn);
        $("#focus .btnBg").css("opacity",0.5);
    
        //为小按钮添加鼠标滑入事件,以显示相应的内容
        $("#focus .btn span").css("opacity",0.4).mouseover(function() {
            index = $("#focus .btn span").index(this);
            showPics(index);
        }).eq(0).trigger("mouseover");
    标签:
  • 上一篇下一篇

    猜您喜欢

    热门推荐