zoukankan      html  css  js  c++  java
  • 【Layui】13 轮播 Carousel

    文档地址:

    https://www.layui.com/demo/carousel.html

    基础轮播:

        <style>
            /* 为了区分效果 */
            div[carousel-item]>*{text-align: center; line-height: 280px; color: #fff;}
            div[carousel-item]>*:nth-child(2n){background-color: #009688;}
            div[carousel-item]>*:nth-child(2n+1){background-color: #5FB878;}
            #test2 div[carousel-item]>*{line-height: 120px;}
        </style>
    
    
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend>常规轮播</legend>
    </fieldset>
    
    <div class="layui-carousel" id="test1" lay-filter="test1">
        <div carousel-item="">
            <div>条目1</div>
            <div>条目2</div>
            <div>条目3</div>
            <div>条目4</div>
            <div>条目5</div>
        </div>
    </div>
    
    <div class="layui-carousel" id="test2" style="margin-top: 15px;">
        <div carousel-item="">
            <div>条目1</div>
            <div>条目2</div>
        </div>
    </div>
    
    <script type="text/javascript">
        layui.use(['carousel', 'form'], function(){
            let form = layui.form;
            let carousel = layui.carousel;
            //常规轮播
            carousel.render({
                elem: '#test1'
                ,arrow: 'always'
            });
    
            //改变下时间间隔、动画类型、高度
            carousel.render({
                elem: '#test2'
                ,interval: 1800
                ,anim: 'fade'
                ,height: '120px'
            });
        });
    </script>

    设置轮播图的容器标签:

    id属性用于定位渲染

    <div class="layui-carousel" id="test1" lay-filter="test1">

    设置轮播图的轮播项的容器标签:

    <div carousel-item="">

    里面的一个一个即轮播项:

            <div>条目1</div>
            <div>条目2</div>
            <div>条目3</div>
            <div>条目4</div>
            <div>条目5</div>

    图片轮播图:

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
        <legend>填充轮播元素 - 以图片为例</legend>
    </fieldset>
    
    <div class="layui-carousel" id="test10">
        <div carousel-item="">
            <div><img src="${pageContext.request.contextPath}/resource/img/37864.jpg"></div>
            <div><img src="${pageContext.request.contextPath}/resource/img/884938.png"></div>
            <div><img src="${pageContext.request.contextPath}/resource/img/1083612.png"></div>
            <div><img src="${pageContext.request.contextPath}/resource/img/1083878.png"></div>
            <div><img src="${pageContext.request.contextPath}/resource/img/1084102.jpg"></div>
        </div>
    </div>
    
    <script type="text/javascript">
        layui.use(['carousel', 'form'], function(){
            let form = layui.form;
            let carousel = layui.carousel;
    
            //图片轮播
            carousel.render({
                elem: '#test10'
                , '778px'
                ,height: '440px'
                ,interval: 5000
            });
        });
    </script>

  • 相关阅读:
    STL--sort源码分析
    进程和线程的区别
    static 关键字 静态成员变量及静态成员函数
    二叉树遍历总结 先序、中序、后续、广度、深度
    C++用new和不用new创建类对象区别
    传输层--TCP和UDP的区别
    传输层的作用
    微信商户/H5支付申请 被拒原因:网站存在不实内容或不安全信息
    Oracle本地网络服务名配置
    存储过程常用技巧
  • 原文地址:https://www.cnblogs.com/mindzone/p/13407828.html
Copyright © 2011-2022 走看看