第十六节(项目实战6-图片滚播器)

<style type="text/css">
            *{margin:0;padding:0;}
            body{font-size:12px;font-family:"微软雅黑";color:#666;height:1500px;}
            img{border:0;}

            /*banner start*/
            .banner{width:100%;height:350px;margin-top:px;}
            .banner .b_adv{width:1200px;height:50px;margin:0 auto;position:relative;}
            .banner .b_adv a{position:absolute;top:0;left:220px;}
            .banner .b_bg{height:300px;background:#4a4d9c;z-index:1;}
            .banner .b_bg .b_con{width:1200px;height:300px;margin:0 auto;
                position:relative;z-index:2;
            }

            /*focus start*/
            .banner .b_bg .b_con .focus{width:760px;height:300px;
                position:absolute;left:220px;top:0;z-index:3;overflow:hidden;}
            .banner .b_bg .b_con .focus .f_pic{position:relative;}
            .banner .b_bg .b_con .focus .f_pic li{list-style:none;}

            .banner .b_bg .b_con .focus .f_btn{height:24px;
                position:absolute;bottom:10px;left:330px;
                /*left:50%;margin-left:-70px;*/
            }
            .banner .b_bg .b_con .focus .f_btn ul{background:#000;display:inline-block;padding:7px 28px;opacity:0.4;filter:alpha(opacity=40); border-radius:15px;}

            .banner .b_bg .b_con .focus .f_btn ul li{width:8px;height:8px;border-radius:10px;border:1px solid #fff;float:left;list-style:none;margin:0 3px;}
            .banner .b_bg .b_con .focus .f_btn ul .no{background:#fff;}

            .banner .b_bg .b_con .focus .f_ear{width:46px;height:70px;display:block;background:url("images/icon.png") no-repeat;
                position:absolute;display:none;
            }
            .banner .b_bg .b_con .focus:hover .f_ear{display:block;}

            .banner .b_bg .b_con .focus .pre{left:10px;top:110px;background-position:-74px 0;}
            .banner .b_bg .b_con .focus .pre:hover{background-position:-172px 0;}

            .banner .b_bg .b_con .focus .next{right:10px;top:110px;background-position:-123px 0;}
            .banner .b_bg .b_con .focus .next:hover{background-position:0 -57px;}
            /*end focus*/

            .clear{clear:both;}
</style>

<body>

    <!--banner start-->
    <div class="banner">

        <div class="b_bg">
            <div class="b_con">

                <!--focus start-->
                <div class="focus">

                    <ul class="f_pic">
                        <li>
                            <a href="#">
                                <img src="images/banner-3.jpg" alt="中山学院" width="760" height="300" />
                            </a>
                        </li>
                        <li>
                            <a href="#">
                                <img src="images/banner-1.jpg" alt="中山学院" width="760" height="300" />
                            </a>
                        </li>
                        <li>
                            <a href="#">
                                <img src="images/banner-2.jpg" alt="中山学院" width="760" height="300" />
                            </a>
                        </li>
                        <li>
                            <a href="#">
                                <img src="images/banner-4.jpg" alt="中山学院" width="760" height="300" />
                            </a>
                        </li>
                        <li>
                            <a href="#">
                                <img src="images/banner-5.jpg" alt="中山学院" width="760" height="300" />
                            </a>
                        </li>
                    </ul>
                    <div class="f_btn">
                        <ul>
                            <li class="no" data-color="#4E4D9B"></li>
                            <li data-color="#A136D2"></li>
                            <li data-color="#6766CE"></li>
                            <li data-color="#563481"></li>
                            <li data-color="#009DE4"></li>
                        </ul>
                    </div>

                    <a href="#" class="f_ear pre"></a>
                    <a href="#" class="f_ear next"></a>

                </div>
                <!--end focus-->

            </div>
        </div>

    </div>
    <!--end banner-->

<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
    $(function(){
        // 焦点图切换
        var index = 0;
        // 轮展图切换
        $(".f_btn").find("li").mouseover(function(){
            // 控制小按钮
            $(this).addClass("no").siblings().removeClass("no");
            var _index = $(this).index(); // 获取当前选中的索引
            index = _index; // 重新赋值
            $(".f_pic").find("li").eq(_index).fadeIn("slow").siblings().hide(); // 联动切换
            // 切换背景颜色
            var background = $(this).data("color");
            $(this).parents(".b_bg").css("background",background);
        });

        // 下一张
        $(".next").click(function(){
            index++;
            var length = $(".f_pic").find("li").length;
            if(index >= length){
                index = 0;
            }
            // 切换背景颜色
            var background = $(".f_btn").find("li").eq(index).data("color");
            $(this).parents(".b_bg").css("background",background);
            // 联动小按钮
            $(".f_btn").find("li").eq(index).addClass("no").siblings().removeClass("no");
            $(".f_pic").find("li").eq(index).fadeIn("slow").siblings().hide(); // 联动切换
        });

        // 上一张
        $(".pre").click(function(){
            index--;
            var length = $(".f_pic").find("li").length;
            if(index < 0){
                index = length - 1;
            }
            // 切换背景颜色
            var background = $(".f_btn").find("li").eq(index).data("color");
            $(this).parents(".b_bg").css("background",background);
            // 联动小按钮
            $(".f_btn").find("li").eq(index).addClass("no").siblings().removeClass("no");
            $(".f_pic").find("li").eq(index).fadeIn("slow").siblings().hide(); // 联动切换
        });

        // 自动切换,一般不使用setTimeout只执行一次
        setInterval(function(){
            index++;
            var length = $(".f_pic").find("li").length;
            if(index >= length){
                index = 0;
            }
            // 切换背景颜色
            var background = $(".f_btn").find("li").eq(index).data("color");
            $(".b_bg").css("background",background);
            // 联动小按钮
            $(".f_btn").find("li").eq(index).addClass("no").siblings().removeClass("no");
            $(".f_pic").find("li").eq(index).fadeIn("slow").siblings().hide(); // 联动切换
        },2000);

    });

</script>

</body>

				
时间: 2024-08-10 15:09:05

第十六节(项目实战6-图片滚播器)的相关文章

第三百一十六节,Django框架,中间件

第三百一十六节,Django框架,中间件 django 中的中间件(middleware),在django中,中间件其实就是一个类,在请求到来和结束后,django会根据自己的规则在合适的时机执行中间件中相应的方法. 在django项目的settings模块中,有一个 MIDDLEWARE变量,其中每一个元素就是一个中间件(也就是一个中间件模块的一个类),如下. settings模块中 #中间件 MIDDLEWARE = [ 'django.middleware.security.Securit

第一百二十六节,JavaScript,XPath操作xml节点

第一百二十六节,JavaScript,XPath操作xml节点 学习要点: 1.IE中的XPath 2.W3C中的XPath 3.XPath跨浏览器兼容 XPath是一种节点查找手段,对比之前使用标准DOM去查找XML中的节点方式,大大降低了查找难度,方便开发者使用.但是,DOM3级以前的标准并没有就XPath做出规范:直到DOM3在首次推荐到标准规范行列.大部分浏览器实现了这个标准,IE则以自己的方式实现了XPath. 一.IE中的XPath 在IE8及之前的浏览器,XPath是采用内置基于A

centos mysql 优化 第十六节课

centos mysql  优化  第十六节课 f

第三百七十六节,Django+Xadmin打造上线标准的在线教育平台—创建用户操作app,在models.py文件生成5张表,用户咨询表、课程评论表、用户收藏表、用户消息表、用户学习表

第三百七十六节,Django+Xadmin打造上线标准的在线教育平台-创建用户操作app,在models.py文件生成5张表,用户咨询表.课程评论表.用户收藏表.用户消息表.用户学习表 创建名称为app_operation的用户操作APP,写数据库操作文件models.py models.py文件 #!/usr/bin/env python # -*- coding:utf-8 -*- from __future__ import unicode_literals from datetime i

第三百五十六节,Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy分布式爬虫要点

第三百五十六节,Python分布式爬虫打造搜索引擎Scrapy精讲-scrapy分布式爬虫要点 1.分布式爬虫原理 2.分布式爬虫优点 3.分布式爬虫需要解决的问题

第三百八十六节,Django+Xadmin打造上线标准的在线教育平台—HTML母版继承

第三百八十六节,Django+Xadmin打造上线标准的在线教育平台-HTML母版继承 母板-子板-母板继承 母板继承就是访问的页面继承一个母板,将访问页面的内容引入到母板里指定的地方,组合成一个新页面返回给浏览器 一般母板里都是写的一个网页里不变的地方,也就是通用的地方,被继承页(访问页)都是每个页面不同的地方,也就是将页面不同的地方引入到母板组合成一个新页面返回浏览器 母板里一般都是网页的.头部.底部.头部底部css.头部底部js 被继承页(访问页)里一般都是新内容,新内容的css和js 母

第二百五十一节,Bootstrap项目实战--响应式轮播图

Bootstrap项目实战--响应式轮播图 学习要点: 1.响应式轮播图 本节课我们要在导航条的下方做一张轮播图,自动播放最新的重要动态. 一.响应式轮播图 响应式轮播图

Android高级图片滚动控件,编写3D版的图片轮播器

转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/17482089 大家好,好久不见了,最近由于工作特别繁忙,已经有一个多月的时间没写博客了,我也是深感惭愧.那么今天的这篇既然是阔别了一个多月的文章,当然要带来更加给力点的内容了,那么话不多说,赶快进入到今天的正题吧. 说 到图片轮播器,很多的Android应用中都会带有这个功能,比如说网易新闻.淘宝等.最新我们公司的一款应用也加入了这个功能,并且在图片轮播的基础上 还增加了三维立体

UISCrollView —— 图片轮播器实现(三)——(第二讲)

1. 所用知识点 1> UIScrollView的基本属性,和UIPageControl设置,还有就是要用到NSTimer来定时实现UIScrollView的图片轮播 2> NSTimer简单介绍: 2.1  NSTimer叫做“定时器”,它的作用如下 * 在指定的时间执行指定的任务 * 每隔一段时间执行指定的任务 2.2  NSTimer简单使用: 1> 调用下面的方法就会开启一个定时任务 + (NSTimer *)scheduledTimerWithTimeInterval:(NST