js+c3变色轮播图

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js+c3变色轮播图相关的知识,希望对你有一定的参考价值。

<html>

<head>

    <title>原生JS轮播</title>

    <meta charset="utf-8" />

    <style>

             *{margin:0;padding:0}

             ul{border:1px solid #eee;width:100%;height:300px;position:relative}

             li{width:100%;height:300px;position:absolute;text-align:center;font-size:100px;line-height:300px;top:0px;}

             ul>li:nth-child(1){background:red}

             ul>li:nth-child(2){background:blue}

             ul>li:nth-child(3){background:chartreuse}

             ul>li:nth-child(4){background:darkseagreen}

            

    </style>

</head>

<body>

         <div>

       <ul id="der">

                   <li>第一章</li>

                   <li>第二章</li>

                   <li>第三章</li>

                   <li>第四章</li>

       </ul>

    </div>

   

    <script>

             dimo("der")

             function dimo(x){

                       par=document.getElementById(x);

                      

                       childs=par.childNodes

                       for(i=0;i<childs.length;i++)

                                {

                                         if(childs[i].nodeType!==1)

                                         {

                                                   par.removeChild(childs[i])

                                         }

 

  更多资料每日分享加群      120342833      验证回答      ZZ      

          

                                }

                                show=0

                                setInterval(function(){

                                         show++

                                         if(show>childs.length-1)

                                         {

                                                   show=0

                                         }

                                        

                                         for(i=0;i<childs.length;i++)

                                         {

                                                   childs[i].style.opacity="0"

                                                   childs[i].style.zIndex="-2"

                                                   childs[i].style.transition="all 0.35s"

                                         }

                                         childs[show].style.opacity="1"

                                         childs[show].style.zIndex="1"

                                },2000)

                      

             }

            

    </script>

</body>

</html>

以上是关于js+c3变色轮播图的主要内容,如果未能解决你的问题,请参考以下文章

轮播图测试点

react-native构建基本页面1---轮播图+九宫格

vue_cli轮播图--swiper插件

做一个前端网页送给女朋友~轮播图+纪念日

C3属性的轮播图(持续更新)

JS---part5 课程介绍 & part4 复习