文档地址:

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'
,width: '778px'
,height: '440px'
,interval: 5000
});
});
</script>

【Layui】13 轮播 Carousel的更多相关文章

  1. thinkphp标签实现bootsrtap轮播carousel实例

    thinkphp标签实现bootsrtap轮播carousel实例由于轮播carousel第一个div需要设置active样式才能正常显示,上面的圆点也同样需要数字,使用volist标签在循环的同时可 ...

  2. Bootstrap历练实例:轮播(carousel)

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...

  3. Bootstrap 历练实例-轮播(carousel)插件的事件

    事件 下表列出了轮播(Carousel)插件中要用到的事件.这些事件可在函数中当钩子使用. 事件 描述 实例 slide.bs.carousel 当调用 slide 实例方法时立即触发该事件. $(' ...

  4. Bootstrap 历练实例-轮播(carousel)插件方法

    方法 下面是一些轮播(Carousel)插件中有用的方法: 方法 描述 实例 .carousel(options) 初始化轮播为可选的 options 对象,并开始循环项目. $('#identifi ...

  5. Bootstrap 轮播(Carousel)插件

    轮播插件是一种灵活的响应式的向站点添加滑块的方式.除此之外,内容也是非常灵活的.可是图像,内嵌框架,视频或者其它您想的放置任何内容的类型. 下面是一个简单的幻灯片,使用轮播(carousel)插件显示 ...

  6. layui(八)——轮播图常见用法总结

    carousel 是 layui 2.0 版本中新增的全新模块,主要适用于跑马灯/轮播等交互场景.它可以满足任何类型内容的轮播式切换操作,更可以胜任 FullPage (全屏上下轮播)的需求,简洁而不 ...

  7. Bootstrap的js插件之轮播(carousel)

    轮播请查看下面演示样例.基本已经涵盖最经常使用的一个轮播 <!DOCTYPE html> <html lang="en"> <head> < ...

  8. BootStrap 轮播 Carousel

    参考 http://wrongwaycn.github.io/bootstrap/docs/javascript.html#collapse 同样 启动方式有2种 一种是在div的class中加  另 ...

  9. 关于Layui 响应式移动端轮播图的问题

    用layui做轮播图,在手机上宽度异常, 可通过以下方法解决, 不喜欢layui的同学可以选择Swiper // 轮播图 layui.use('carousel', function () { var ...

  10. layui常用插件(一) 轮播图

    轮播图 <html lang="en"> <head> <meta charset="UTF-8"> <meta ht ...

随机推荐

  1. kvm链接克隆虚拟机迁移到openstack机器的实验

    总结 如果是完整克隆的那种虚拟机,是可以直接在openstack使用的,如果镜像格式没问题的话. 因为kvm虚拟机大部分都是链接克隆出来的镜像,不可用直接复制使用,所以需要创建新的镜像文件 创建空盘: ...

  2. 微信实名认证申请单报错:请求中含有未在API文档中定义的参数

    完整错误: {"code":"PARAM_ERROR","detail":{"location":null," ...

  3. python 文件查找及截取字符串 (替换,分割) demo

    #"F:\\test.txt" ''' # 例1:字符串截取 str = '12345678' print str[0:1] # 例2:字符串替换 str = 'akakak' s ...

  4. xxlJob端口号及故障转移设置,解决负载均衡调度任务执行

    xxlJob端口号及故障转移设置,解决负载均衡调度任务执行 my.xxljob.executorPort = 1162 my.xxljob.executorAppName = myService-jo ...

  5. PackageScanner

    package com.cmb.cox.utils;import com.alibaba.fastjson.JSON;import com.alibaba.fastjson.JSONObject;im ...

  6. 卷积神经网络-AlexNet

    AlexNet 一些前置知识 top-1 和top-5错误率 top-1错误率指的是在最后的n哥预测结果中,只有预测概率最大对应的类别是正确答案才算预测正确. top-5错误率指的是在最后的n个预测结 ...

  7. python _XMLParser.__init__()初始化失败,提示“takes 1 positional argument but 4 were given”

    问题: 在一个新的环境下,执行openpyxl相关的操作,初始化时,逐步执行,需要调到 ElementTree.py _XMLParser.__init__(self, html, target, e ...

  8. Cython编译报错“numpy/arrayobject.h: No such file or directory”解决方案

    问题背景 Cython是用来加速Python程序性能的一个工具,其基本使用逻辑就是将类Python代码(*.pyx扩展格式)编译成\(*.c,*.so\)动态链接库文件,然后就可以在正常的Python ...

  9. 3562-Qt工程编译说明、GPU核心使用说明

  10. xlookup与vlookup的区别

    区别还是很大的,vlookup暂时扔不了.