Blogger Information
Blog 43
fans 1
comment 0
visits 33909
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Layui常用组件
蔚蓝世纪
Original
1117 people have browsed it

layui常用组件输出效果在线预览
Layui常用组件有:轮播图、按钮、弹出层、日期与时间、文件上传、布局、进度条、表格等。
演示代码:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <link rel="stylesheet" type="text/css" href="layui/css/layui.css">
  7. <script type="text/javascript" src="layui/layui.js"></script>
  8. <style type="text/css">
  9. .item{
  10. padding:20px;
  11. }
  12. </style>
  13. <title>Document</title>
  14. </head>
  15. <body style="background:#f1f1f1">
  16. <!-- 轮播图 -->
  17. <div class="layui-carousel" id="test1">
  18. <div carousel-item>
  19. <div style="background:#ff0000">图片1</div>
  20. <div style="background:#fe2152">图片2</div>
  21. <div style="background:#ff3326">图片3</div>
  22. <div style="background:#ff7708">图片4</div>
  23. <div style="background:#ff1251">图片5</div>
  24. </div>
  25. </div>
  26. <!-- 按钮 -->
  27. <div style="padding:50px;">
  28. <button>原生按钮</button>
  29. <button class="layui-btn">默认按钮</button>
  30. <button class="layui-btn layui-btn-danger layui-btn-lg">警告按钮</button>
  31. <!-- 弹出层 -->
  32. <button class="layui-btn layui-btn-normal" onclick="popup()">默认按钮</button>
  33. </div>
  34. <!-- 日期与时间 -->
  35. <div class="layui-form">
  36. <div class="layui-form-item">
  37. <label class="layui-form-label">开始时间</label>
  38. <div class="layui-input-inline">
  39. <input type="text" class="layui-input" id="mydate">
  40. </div>
  41. </div>
  42. </div>
  43. <!-- 文件上传 -->
  44. <div class="layui-form">
  45. <div class="layui-form-item">
  46. <label class="layui-form-label">文件上传</label>
  47. <div class="layui-input-inline">
  48. <input type="file" >
  49. </div>
  50. </div>
  51. </div>
  52. <!-- 布局 -->
  53. <div class="layui-row">
  54. <div class="layui-col-sm4 item">
  55. <div class="layui-card">
  56. <div class="layui-card-header">卡片面板1</div>
  57. <div class="layui-card-body">
  58. 卡片式面板面板通常用于非白色背景色的主体内<br>
  59. 从而映衬出边框投影
  60. </div>
  61. </div>
  62. </div>
  63. <div class="layui-col-sm4 item">
  64. <div class="layui-card">
  65. <div class="layui-card-header">卡片面板2</div>
  66. <div class="layui-card-body">
  67. 卡片式面板面板通常用于非白色背景色的主体内<br>
  68. 从而映衬出边框投影
  69. </div>
  70. </div>
  71. </div>
  72. <div class="layui-col-sm4 item">
  73. <div class="layui-card">
  74. <div class="layui-card-header">卡片面板3</div>
  75. <div class="layui-card-body">
  76. 卡片式面板面板通常用于非白色背景色的主体内<br>
  77. 从而映衬出边框投影
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. <!-- 进度条 -->
  83. <div style="margin:40px;">进度条
  84. <div class="layui-progress" lay-showPercent="yes">
  85. <div class="layui-progress-bar layui-bg-orange" lay-percent="20%"></div>
  86. </div>
  87. </div>
  88. <div style="margin:40px;">进度条
  89. <div class="layui-progress" lay-showPercent="yes">
  90. <div class="layui-progress-bar layui-bg-blue" lay-percent="2/3"></div>
  91. </div>
  92. </div>
  93. <div style="margin:40px;">进度条
  94. <div class="layui-progress" lay-showPercent="yes">
  95. <div class="layui-progress-bar layui-bg-red" lay-percent="60%"></div>
  96. </div>
  97. </div>
  98. <!-- 表格 -->
  99. <div>
  100. <table class="layui-table">表格
  101. <colgroup>
  102. <col width="150">
  103. <col width="200">
  104. <col>
  105. </colgroup>
  106. <thead>
  107. <tr>
  108. <th>昵称</th>
  109. <th>加入时间</th>
  110. <th>签名</th>
  111. </tr>
  112. </thead>
  113. <tbody>
  114. <tr>
  115. <td>木子</td>
  116. <td>2016-11-29</td>
  117. <td>人生就像是一场修行</td>
  118. </tr>
  119. <tr>
  120. <td>闲心</td>
  121. <td>2016-11-28</td>
  122. <td>于千万人之中遇见你所遇见的人,于千万年之中,时间的无涯的荒野里…</td>
  123. </tr>
  124. <tr>
  125. <td>西风</td>
  126. <td>2020-06-02</td>
  127. <td>人们总是生活在无尽的悔恨中</td>
  128. </tr>
  129. </tbody>
  130. </table>
  131. </div>
  132. </body>
  133. </html>
  134. <script>
  135. //注意进度条依赖 element 模块,否则无法进行正常渲染和功能性操作
  136. layui.use(['element','layer','laydate','carousel'], function(){
  137. var element = layui.element;
  138. layer = layui.layer;
  139. laydate = layui.laydate;
  140. laydate.render({
  141. elem:'#mydate'
  142. });
  143. var carousel = layui.carousel;
  144. //建造实例
  145. carousel.render({
  146. elem: '#test1'
  147. ,width: '100%' //设置容器宽度
  148. ,arrow: 'always' //始终显示箭头
  149. //,anim: 'updown' //切换动画方式
  150. });
  151. });
  152. function popup(){
  153. // layer.alert('我是layer alert',{icon:1});
  154. // layer.msg('我是layer alert',{icon:1});
  155. layer.open({
  156. type: 2,
  157. title: 'layer mobile页',
  158. shadeClose: true,
  159. shade: 0.8,
  160. area: ['980px', '90%'],
  161. content: 'https://www.php.cn/' //iframe的url
  162. });
  163. }
  164. </script>

输出效果:

总结:
Layui真的是太好用啦,怕用久了,手也懒了,脑子也懒了,把基本代码都给忘了。

Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:觉得layui好用, 那是你用过的ui还是太少了
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post