轮播图动画

简介: 轮播图动画

1.普通轮播


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* 轮播图区域 */
         .box{
            width: 560px;
            height: 300px;
            margin: 50px auto;
            overflow: hidden;
            position: relative;
        }
        /* 图片滚动区域 */
        .content{
            font-size: 0;
            width: 3000px;
            height: 300px;
            display: inline-block;
            position: absolute;
        }
        /* 下方序列按钮 */
        .btns{
            position: absolute;
            bottom: 30px;
            /* background-color: yellow; */
            width: 560px;
            text-align: center;
        }
        .btns span{
            padding: 6px;
            border-radius: 50%;
            background-color: white;
            font-size: 0px;
            margin: 0 8px;
        }
        .btns .choose{
            background-color: red;
        }
        .pre,
        .next{
            position: absolute;
            top: 50%;
            color: white;
            font-size: 30px;
            right: 0px;
            height: 50px;
            width: 30px;
            text-align: center;
            line-height: 50px;
            background-color: rgba(0,0,0,0.6);
        }
        .pre{
            left: 0;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="content">
            <img src="img/0.jpg" alt="">
            <img src="img/1.jpg" alt="">
            <img src="img/2.jpg" alt="">
            <img src="img/3.jpg" alt="">
            <img src="img/4.jpg" alt="">
        </div>
        <div class="btns">
            <span class="choose"></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
        </div>
        <div class="pre">&lt;</div>
        <div class="next">&gt;</div>       
    </div>
    <script src="../js/jquery-3.6.0.min.js"></script>
    <script>
        var $img = $('.content');
        var $btns = $('.btns span');
        var $pre = $('.pre');
        var $next = $('.next');
        var index =0;
        var timebar;
        // 轮播函数 
        function startInterval(){
            // 轮播定时器
            timebar = setInterval(function(){
                if(index >=4){
                    index = 0;
                }else{
                    index++;
                }
                // 调用切换动画
                change();       
                },2000);
            }
        // 切换动画函数
        function change(fn){
            $img.stop(true).animate({left: -560*index},800);         
            $btns.eq(index).addClass('choose');
            $btns.eq(index).siblings().removeClass('choose');
            fn && fn();
        }
        // 加载完毕启动动画
        startInterval();
        // 绑定点击向左轮播
        $pre.click(function(){
            // 清除timebar定时器
            clearInterval(timebar);
            // 边界判断
            if(index <= 0){
                index = 4;
            }else{
                index--;
            }
            // 完成后,加入定时器
            change(startInterval);
        })
        // 绑定点击向右轮播
        $next.click(function(){
            // 清除timebar定时器
            clearInterval(timebar);
            // 边界判断
            if(index >= 4){
                index = 0;
            }else{
                index++;
            }
            // 完成后,加入定时器
            change(startInterval);
        })
        // 绑定点击下标按钮轮播
        $btns.click(function(){
            // 清除timebar定时器
            clearInterval(timebar);
            index = $(this).index();
            change(startInterval);
        })
    </script>
</body>
</html>


2.猫腻轮播图


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* 轮播图区域 */
         .box{
            width: 560px;
            height: 300px;
            margin: 50px auto;
            overflow: hidden;
            position: relative;
        }
        /* 图片滚动区域 */
        .content{
            font-size: 0;
            width: 5000px;
            height: 300px;
            display: inline-block;
            position: absolute;
        }
        /* 下方序列按钮 */
        .btns{
            position: absolute;
            bottom: 30px;
            /* background-color: yellow; */
            width: 560px;
            text-align: center;
        }
        .btns span{
            padding: 6px;
            border-radius: 50%;
            background-color: white;
            font-size: 0px;
            margin: 0 8px;
        }
        .btns .choose{
            background-color: red;
        }
        .pre,
        .next{
            position: absolute;
            top: 50%;
            color: white;
            font-size: 30px;
            right: 0px;
            height: 50px;
            width: 30px;
            text-align: center;
            line-height: 50px;
            background-color: rgba(0,0,0,0.6);
        }
        .pre{
            left: 0;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="content">
            <img src="img/4.jpg" alt="">
            <img src="img/0.jpg" alt="">
            <img src="img/1.jpg" alt="">
            <img src="img/2.jpg" alt="">
            <img src="img/3.jpg" alt="">
            <img src="img/4.jpg" alt="">
            <img src="img/0.jpg" alt="">
        </div>
        <div class="btns">
            <span class="choose"></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
        </div>
        <div class="pre">&lt;</div>
        <div class="next">&gt;</div>       
    </div>
    <script src="../js/jquery-3.6.0.min.js"></script>
    <script>
        var $img = $('.content');
        var $btns = $('.btns span');
        var $pre = $('.pre');
        var $next = $('.next');
        var index = 1;
        var timebar;
        // 轮播函数 
        function startInterval(){
            // 轮播定时器
            timebar = setInterval(function(){
                index ++;
                if(index >= 7){
                    index = 0;
                }
                // 调用切换动画
                change();       
            },2000);
        }
        // 切换动画函数
        function change(fn){
            $img.stop(true).animate({left: -560*index},500,function(){
                if(index === 6){
                    index = 1;
                    $img.css('left',-560*index);
                }else if(index ===0){
                    index = 5;
                    $img.css('left',-560*index)
                }
                $btns.eq(index-1).addClass('choose');
                $btns.eq(index-1).siblings().removeClass('choose');
                fn && fn();
            });         
        }
        // 默认第一张显示index = 1
        $img.css('left',-560*index);
        // 加载完毕启动动画
        startInterval();     
        // 绑定点击向左轮播
        $pre.click(function(){
            // 清除timebar定时器
            clearInterval(timebar);
            // 边界判断
            index--;
            if(index < 0){
                index = 4;
            }
            // 完成后,加入定时器
            change(startInterval);
        })
        // 绑定点击向右轮播
        $next.click(function(){
            // 清除timebar定时器
            clearInterval(timebar);
            // 边界判断
            index++;
            if (index >= 7) {
                index = 0;
            }
            // 完成后,加入定时器
            change(startInterval);
        })
        // 绑定点击下标按钮轮播
        $btns.click(function(){
            // 清除timebar定时器
            clearInterval(timebar);
            index = $(this).index()+1;
            change(startInterval);
        })
    </script>
</body>
</html>


3.最后一张设置猫腻图


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* 轮播图区域 */
         .box{
            width: 560px;
            height: 300px;
            margin: 50px auto;
            overflow: hidden;
            position: relative;
        }
        /* 图片滚动区域 */
        .content{
            font-size: 0;
            width: 5000px;
            height: 300px;
            display: inline-block;
            position: absolute;
        }
        /* 下方序列按钮 */
        .btns{
            position: absolute;
            bottom: 30px;
            /* background-color: yellow; */
            width: 560px;
            text-align: center;
        }
        .btns span{
            padding: 6px;
            border-radius: 50%;
            background-color: white;
            font-size: 0px;
            margin: 0 8px;
        }
        .btns .choose{
            background-color: red;
        }
        .pre,
        .next{
            position: absolute;
            top: 50%;
            color: white;
            font-size: 30px;
            right: 0px;
            height: 50px;
            width: 30px;
            text-align: center;
            line-height: 50px;
            background-color: rgba(0,0,0,0.6);
        }
        .pre{
            left: 0;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="content">
            <img src="img/0.jpg" alt="">
            <img src="img/1.jpg" alt="">
            <img src="img/2.jpg" alt="">
            <img src="img/3.jpg" alt="">
            <img src="img/4.jpg" alt="">
            <img src="img/0.jpg" alt="">
        </div>
        <div class="btns">
            <span class="choose"></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
        </div>
        <div class="pre">&lt;</div>
        <div class="next">&gt;</div>       
    </div>
    <script src="../js/jquery-3.6.0.min.js"></script>
    <script>
        var $img = $('.content');
        var $btns = $('.btns span');
        var $pre = $('.pre');
        var $next = $('.next');
        var index = 0;
        var timebar;
        // 轮播函数 
        function startInterval(){
            // 轮播定时器
            timebar = setInterval(function(){
                index ++;
                if(index >= 6){
                    index = 0;
                }
                // 调用切换动画
                change();       
            },2000);
        }
        // 切换动画函数
        function change(fn){
            $img.stop(true).animate({left: -560*index},500,function(){
                if(index === 5){
                    index = 0;
                    $img.css('left',-560*index);
                }
                $btns.eq(index).addClass('choose');
                $btns.eq(index).siblings().removeClass('choose');
                fn && fn();
            });         
        }
        // 默认第一张显示index = 1
        $img.css('left',-560*index);
        // 加载完毕启动动画
        startInterval();     
        // 绑定点击向左轮播
        $pre.click(function(){
            // 清除timebar定时器
            clearInterval(timebar);
            // 边界判断
            index--;
            if(index < 0){
                index = 4;
                // 
                $img.css('left',-560*5)
            }
            // 完成后,加入定时器
            change(startInterval);
        })
        // 绑定点击向右轮播
        $next.click(function(){
            // 清除timebar定时器
            clearInterval(timebar);
            // 边界判断
            index++;
            if (index >= 6) {
                index = 0;
            }
            // 完成后,加入定时器
            change(startInterval);
        })
        // 绑定点击下标按钮轮播
        $btns.click(function(){
            // 清除timebar定时器
            clearInterval(timebar);
            index = $(this).index();
            change(startInterval);
        })
    </script>
</body>
</html>


4.三点轮播图



相关文章
|
机器学习/深度学习 算法 语音技术
深入浅出:使用深度学习进行图像识别
【9月更文挑战第19天】本文将带你进入深度学习的神奇世界,了解如何通过神经网络实现图像识别。我们将从基础理论出发,逐步深入到实际应用,让你对深度学习在图像处理领域的强大能力有一个全面的认识。无论你是初学者还是有一定基础的学习者,都能从中获得新的启发和理解。让我们一起探索这个充满可能性的领域吧!
|
6月前
|
机器学习/深度学习 人工智能 测试技术
昆仑万维开源 Skywork R1V:开源多模态推理核弹!视觉链式分析超越人类专家
Skywork R1V 是昆仑万维开源的多模态思维链推理模型,具备强大的视觉链式推理能力,能够在多个权威基准测试中取得领先成绩,推动多模态推理模型的发展。
180 4
昆仑万维开源 Skywork R1V:开源多模态推理核弹!视觉链式分析超越人类专家
|
12月前
|
机器学习/深度学习 人工智能 供应链
工业互联网平台
工业互联网平台
675 3
|
机器学习/深度学习 人工智能 运维
智能化运维:AI在IT管理中的创新应用
【7月更文挑战第15天】本文探讨了人工智能(AI)如何革新传统的IT运维模式,通过智能自动化、实时分析和预测性维护,显著提高运维效率和准确性。文章将深入分析AI技术在故障检测与解决、资源优化配置以及安全监控等方面的具体应用案例,并讨论实施AI时可能遇到的挑战和解决方案。
330 2
|
10月前
|
UED 开发者
鸿蒙next版开发:ArkTS组件通用属性(边框设置)
在HarmonyOS 5.0中,ArkTS提供了丰富的边框设置属性,允许开发者自定义组件的边框样式,提升应用的视觉效果和用户体验。本文详细解读了border属性的使用方法,并提供了示例代码,展示了如何设置不同边的边框宽度、颜色、圆角和样式。边框设置在UI开发中具有重要作用,如区分组件、强调重要元素和美化界面。
975 6
|
10月前
|
JSON API 数据安全/隐私保护
拍立淘按图搜索API接口返回数据的JSON格式示例
拍立淘按图搜索API接口允许用户通过上传图片来搜索相似的商品,该接口返回的通常是一个JSON格式的响应,其中包含了与上传图片相似的商品信息。以下是一个基于淘宝平台的拍立淘按图搜索API接口返回数据的JSON格式示例,同时提供对其关键字段的解释
|
数据采集 API 网络安全
Python Requests代理使用入门指南
《Python Requests 代理使用入门指南》将带你深入了解如何使用Python Requests库来配置HTTP代理,并灵活处理各种权限和服务器响应问题。从代理服务器的基础知识,到代理认证与授权设置,本指南为初学者提供了全面的教学内容。
Python Requests代理使用入门指南
|
人工智能 并行计算 数据安全/隐私保护
铅华洗尽,粉黛不施,人工智能AI基于ProPainter技术去除图片以及视频水印(Python3.10)
视频以及图片修复技术是一项具有挑战性的AI视觉任务,它涉及在视频或者图片序列中填补缺失或损坏的区域,同时保持空间和时间的连贯性。该技术在视频补全、对象移除、视频恢复等领域有广泛应用。近年来,两种突出的方案在视频修复中崭露头角:flow-based propagation和spatiotemporal Transformers。尽管两套方案都还不错,但它们也存在一些局限性,如空间错位、时间范围有限和过高的成本。 说白了,你通过AI技术移除水印或者修复一段不清晰的视频,但结果却没法保证连贯性,让人一眼能看出来这个视频或者图片还是缺失状态,与此同时,过高的算力成本也是普通人难以承受的。
铅华洗尽,粉黛不施,人工智能AI基于ProPainter技术去除图片以及视频水印(Python3.10)
|
移动开发 前端开发
基于若依的ruoyi-nbcio流程管理系统自定义业务撤回功能的修复
基于若依的ruoyi-nbcio流程管理系统自定义业务撤回功能的修复
179 0
java contains忽略大小写
java contains忽略大小写
173 2

热门文章

最新文章