文档地址:

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. ETL工具-nifi干货系列 第六讲 处理器JoltTransformJSON

    1.处理器作用 使用Jolt转换JSON数据为其他结构的JSON,成功的路由到'success',失败的'failure'.处理JSON的实用程序不是基于流的,因此大型JSON文档转换可能会消耗大量内 ...

  2. 微信支付(付款码支付,条码支付,刷卡支付)左上角LOGO显示

    微信支付(付款码支付,条码支付,刷卡支付)左上角LOGO显示 如果你上送的sub_appid 公众号(小程序),优先显示你公众号(小程序)的LOGO,如果你的公众号(小程序)未设置LOGO,会显示上游 ...

  3. 夜莺官方文档优化第一弹:手把手教你部署和架构讲解,消灭所有部署失败的 case!干!

    前置说明 各种环境的选型建议 Docker compose 方式:仅仅用于简单测试,不推荐在生产环境使用 Docker compose,升级起来挺麻烦的,除非你对 Docker compose 真的很 ...

  4. redis数据持久化篇

    为什么需要持久化 Redis是个基于内存的数据库. 那服务一旦宕机,内存中的数据将全部丢失. 通常的解决方案是从后端数据库恢复这些数据,但后端数据库有性能瓶颈 如果是大数据量的恢复,1.会对数据库带来 ...

  5. 一个开源且全面的C#算法实战教程

    前言 算法在计算机科学和程序设计中扮演着至关重要的角色,如在解决问题.优化效率.决策优化.实现计算机程序.提高可靠性以及促进科学融合等方面具有广泛而深远的影响.今天大姚给大家分享一个开源.免费.全面的 ...

  6. Excel表格Vlookup跨sheet取值,ISNA函数处理匹配不到的空字符串

    Excel表格Vlookup跨sheet取值 =VLOOKUP($A2,Sheet2!$A$2:$D$15,2,FALSE) $A2 代表当前的Sheet1的单元格,数据类型需要与查找的单元格字段类型 ...

  7. RedHat 6.9 操作系统安装

    重启服务器--按F11--bios boot manager ---选择自己的U盘 通过U盘启动RedHat6.9系统,如图安装界面: 选择Install or upgrade an exising ...

  8. 使用 Spring 实现控制反转和依赖注入

    使用 Spring 实现控制反转和依赖注入 概述 在本文中,我们将介绍IoC(控制反转)和DI(依赖注入)的概念,以及如何在Spring框架中实现它们. 什么是控制反转? 控制反转是软件工程中的一个原 ...

  9. Win11在VMWare中无tpm条件下安装

    Win11在VMWare中无tpm条件下安装 在条件不满足提示的窗口下. 按shift+F10打开cmd, 输入regedit打开注册表, 按如下路径新建三个值后即可 [HKEY_LOCAL_MACH ...

  10. 案例源码公开!分享瑞芯微RK3568J与FPGA的PCIe通信案例,嵌入式必读!

    ​ ARM + FPGA架构有何种优势 近年来,随着中国新基建.中国制造2025的持续推进,单ARM处理器越来越难满足工业现场的功能要求,特别是能源电力.工业控制.智慧医疗等行业通常需要ARM + F ...