zoukankan      html  css  js  c++  java
  • 页面添加滚动图片效果

    1、jsp核心代码如下:

    <div id="bann" class="banner">

    <div id="bann_bg" class="banner_bg"></div>
    <div id="bann_info" class="banner_info"></div>
    <div id="bann_list" class="banner_list">
    <a href="#" target="_blank"><img src="1.jpg" alt="测试图片1" /></a>
    <a href="#" target="_blank"><img src="2.jpg" alt="测试图片2" /></a>
    <a href="#" target="_blank"><img src="3.jpg" alt="测试图片3" /></a>
    <a href="#" target="_blank"><img src="4.jpg" alt="测试图片4" /></a>
    </div>
    </div>

    2、css样式核心代码如下:

    .banner {position:relative;float:left;margin-left:10px; 450px; height:300px; overflow:hidden;}
    .banner_list img{450px; height:300px;border:0}
    .banner_bg {position:absolute; bottom:0;background-color:#000;height:28px;filter: Alpha(Opacity=50);opacity:0.5;z-index:1;cursor:pointer; 400px; }
    .banner_info{position:absolute; bottom:0; left:5px;height:22px;color:#fff;z-index:2;font-size:14px;cursor:pointer}
    .banner_text {position:absolute;120px;z-index:3; right:3px; bottom:3px;}
    .banner_ul {position:absolute;list-style-type:none;z-index:4;margin:0; padding:0; bottom:3px; right:3px;}
    .banner_ul li { 20px;line-height:20px;text-align:center;float:left;display:block;color:#ff6666;border:#e7f2fd 1px solid;background:#FFF;cursor:pointer}
    .banner_ul .banner_on { background:#ff6666;color:#FFF}
    .banner_list a{position:absolute;}

    3、js核心代码如下:
    <script type="text/javascript">

    var Speed = 1; //速度(毫秒)
    var Space = 12; //每次移动(px)
    var PageWidth =220; //翻页宽度
    var fill = 0; //整体移位
    var MoveLock = false;
    var MoveTimeObj;
    var Comp = 0;
    var AutoPlayObj = null;

    $(document).ready(function(){
      $("#bann").picture(5000);//5秒钟切换图片
    });


    jQuery.fn.extend({
    picture:function(t){
    return this.each(function(){
    var id="#"+$(this).attr("id");
    var n = -1, i_count,interval="<ul class='banner_ul'>";
    i_count=$(id+"_list a").length;
    for(var i=0;i<i_count;i++){
    interval+="<li>"+(i+1)+"</li>";
    }
    $(id+"_info").after(interval+"</ul>");
    $(id+" li").click(function(e) {
    e.stopPropagation();
    n=$(this).index();
    $(id+"_info").html($(id+"_list a").eq(n).find("img").attr('alt'));
    $(id+"_list a").filter(":visible").fadeOut(500).parent().children().eq(n).fadeIn(1000);
    $(this).addClass("banner_on");
    $(this).siblings().removeAttr("class");
    });
    interval = setInterval(showAuto, t);
    $(this).hover(function(){clearInterval(interval)}, function(){interval = setInterval(showAuto, t)});
    function showAuto(){
    n = n >=(i_count-1) ? 0 : ++n;
    $(id+" li").eq(n).click();
    }
    showAuto();
    })
    }
    });

    </script>

     

    人的价值体现在不可替代性上
  • 相关阅读:
    LeetCode 32. 最长有效括号(Longest Valid Parentheses)
    LeetCode 141. 环形链表(Linked List Cycle)
    LeetCode 160. 相交链表(Intersection of Two Linked Lists)
    LeetCode 112. 路径总和(Path Sum)
    LeetCode 124. 二叉树中的最大路径和(Binary Tree Maximum Path Sum)
    LightGBM新特性总结
    sql service 事务与锁
    C#泛型实例详解
    C# 中的委托和事件(详解)
    C# DateTime日期格式化
  • 原文地址:https://www.cnblogs.com/zxg0822/p/10191704.html
Copyright © 2011-2022 走看看