文档地址:

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. 工作中常用Less知识点实践总结

    我所理解的Less的一些好处 函数式编程css 自定义变量用于整体主题调整 嵌套语法简化开发复杂度 mixin的写法 .defaultBorder(@width: 10px, @style: soli ...

  2. liquibase常用操作

    1.概述 Liquibase是一个用于跟踪.管理和应用数据库变化的开源的数据库重构工具.它将所有数据库的变化(包括结构和数据)都保存在XML文件中,便于版本控制. 本文旨在将平时工作中常用的一些操作进 ...

  3. Kubernetes监控手册02-宿主监控概述

    咱们这个系列是讲解 Kubernetes 监控,Kubernetes 自身也是要跑在机器上的,那机器的监控自然也是整个体系的一环.机器层面的监控分为两部分,带内网络和带外网络,通过带内网络做监控主要是 ...

  4. es6.6.1 索引的增加,查询,修改,删除

    1.新增 test2/user2/1/_create PUT操作{"name":"qiqi","age":17} 2.查询 test2/us ...

  5. 简约博客V1.1版本上线 + 一套新主题

    Tips:当你看到这个提示的时候,说明当前的文章是由原emlog博客系统搬迁至此的,文章发布时间已过于久远,编排和内容不一定完整,还请谅解` 简约博客V1.1版本上线 + 一套新主题 日期:2017- ...

  6. CSV文件存储

    CSV 文件存储 CSV,全称为 Comma-Separated Values,中文可以叫作逗号分隔值或字符分隔值,其文件以纯文本形式存储表格数据.该文件是一个字符序列,可以由任意数目的记录组成,记录 ...

  7. 剖析 Kafka 消息丢失的原因

    目录 前言 一.生产者导致消息丢失的场景 场景1:消息体太大 解决方案 : 1.减少生产者发送消息体体积 2.调整参数max.request.size 场景2:异步发送机制 解决方案 : 1.使用带回 ...

  8. springboot支持http2

    现在http/3都出来了,但是很多项目还是没有采用https,这个是说不过去的. http3在2022/06/06 正式发布,具体见https://www.163.com/dy/article/H9B ...

  9. ServiceMesh、SideCar和Istio

    Service Mesh简介 Service Mesh直译过来就是服务网格,而他的架构就是一个个微服务组成的网络. Sidecar简介 Service Mesh中的节点就是Sidecar节点. sid ...

  10. 服务器上安装centos7系统遇到的坑

    centos7的安装报错"no controller found" 出现no controller found解决方案1.等待命令行出现 2.输入ls /dev/sd*   找到自 ...