slider.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>镜像站@滑块 - 在线演示 - Layui</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  10. <meta name="apple-mobile-web-app-capable" content="yes">
  11. <meta name="format-detection" content="telephone=no">
  12. <script>
  13. ;!function(){self!==parent&&(location.href="http://www.baidu.com/")}();
  14. </script>
  15. <link rel="stylesheet" href="/public/layui/dist/css/layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css?t=1632428048355" media="all">
  16. <link rel="stylesheet" href="/public/static/css/global.css" tppabs="http://res.layui.com/static/css/global.css?t=1632428048355-19" media="all">
  17. <style>
  18. .demo-slider{margin: 45px 30px; width: 40%;}
  19. </style>
  20. </head>
  21. <body>
  22. <div class="layui-layout layui-layout-admin">
  23. <div class="layui-header header header-demo" autumn>
  24. <div class="layui-fluid">
  25. <a class="logo" href="../index.html" tppabs="http://www.layui.com/">
  26. <img src="/public/static/images/layui/logo.png" tppabs="http://res.layui.com/static/images/layui/logo.png" alt="layui">
  27. </a>
  28. <div class="layui-form layui-hide-xs component" lay-filter="LAY-site-header-component"></div>
  29. <div class="layui-hide-xs site-notice"></div>
  30. <ul class="layui-nav" id="LAY_NAV_TOP">
  31. <li class="layui-nav-item ">
  32. <a href="../doc/index.html" tppabs="http://www.layui.com/doc/">文档</a>
  33. </li>
  34. <li class="layui-nav-item layui-this">
  35. <a href="index.html" tppabs="http://www.layui.com/demo/">示例</a>
  36. </li>
  37. <li class="layui-nav-item">
  38. <a href="javascript:;">
  39. <!--<span class="layui-badge-dot" style="left:0; right: auto; margin: -4px 0 0 5px;"></span>-->
  40. 周边
  41. </a>
  42. <dl class="layui-nav-child layui-nav-child-c">
  43. <dd class="layui-hide-sm layui-show-xs" lay-unselect>
  44. <a href="https://gitee.com/sentsin/layui/issues" target="_blank" rel="nofollow">问题反馈</a>
  45. <hr>
  46. </dd>
  47. <dd lay-unselect><a href="../alone.html" tppabs="http://www.layui.com/alone.html" target="_blank" lay-unselect>独立组件</a></dd>
  48. <dd lay-unselect><a href="../../fly.layui.com/extend/index.html" target="_blank">扩展组件</a></dd>
  49. </dl>
  50. </li>
  51. <li class="layui-nav-item layui-hide-xs">
  52. <a href="http://gitee.com/sentsin/layui/issues" target="_blank" rel="nofollow">反馈</a>
  53. </li>
  54. </ul>
  55. </div>
  56. </div>
  57. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  58. <!--[if lt IE 9]>
  59. <script src="../../other/html5shiv/r29/html5.min.js" tppabs="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  60. <script src="../../other/respond.js/1.4.2/respond.min.js" tppabs="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  61. <![endif]-->
  62. <div class="layui-side layui-bg-black">
  63. <div class="layui-side-scroll">
  64. <ul class="layui-nav layui-nav-tree site-demo-nav">
  65. <li class="layui-nav-item layui-nav-itemed">
  66. <a class="javascript:;" href="javascript:;">演示</a>
  67. <dl class="layui-nav-child">
  68. <dd>
  69. <a href="index.html" tppabs="http://www.layui.com/demo/">调试预览</a>
  70. </dd>
  71. </dl>
  72. </li>
  73. <li class="layui-nav-item layui-nav-itemed">
  74. <a class="javascript:;" href="javascript:;">布局</a>
  75. <dl class="layui-nav-child">
  76. <dd class="">
  77. <a href="grid.html" tppabs="http://www.layui.com/demo/grid.html">栅格</a>
  78. </dd>
  79. <dd class="">
  80. <a href="admin.html" tppabs="http://www.layui.com/demo/admin.html">框架</a>
  81. </dd>
  82. </dl>
  83. </li>
  84. <li class="layui-nav-item layui-nav-itemed">
  85. <a class="javascript:;" href="javascript:;">基本元素</a>
  86. <dl class="layui-nav-child">
  87. <dd class="">
  88. <a href="button.html" tppabs="http://www.layui.com/demo/button.html">按钮</a>
  89. </dd>
  90. <dd class="">
  91. <a href="form.html" tppabs="http://www.layui.com/demo/form.html">表单</a>
  92. </dd>
  93. <dd class="">
  94. <a href="nav.html" tppabs="http://www.layui.com/demo/nav.html">导航 / 面包屑</a>
  95. </dd>
  96. <dd class="">
  97. <a href="menu.html" tppabs="http://www.layui.com/demo/menu.html">基础菜单</a>
  98. </dd>
  99. <dd class="">
  100. <a href="tab.html" tppabs="http://www.layui.com/demo/tab.html">选项卡</a>
  101. </dd>
  102. <dd class="">
  103. <a href="progress.html" tppabs="http://www.layui.com/demo/progress.html">进度条</a>
  104. </dd>
  105. <dd class="">
  106. <a href="panel.html" tppabs="http://www.layui.com/demo/panel.html">面板</a>
  107. </dd>
  108. <dd class="">
  109. <a href="badge.html" tppabs="http://www.layui.com/demo/badge.html">徽章</a>
  110. </dd>
  111. <dd class="">
  112. <a href="timeline.html" tppabs="http://www.layui.com/demo/timeline.html">时间线</a>
  113. </dd>
  114. <dd class="">
  115. <a href="table-element.html" tppabs="http://www.layui.com/demo/table-element.html">静态表格</a>
  116. </dd>
  117. <dd class="">
  118. <a href="anim.html" tppabs="http://www.layui.com/demo/anim.html">动画</a>
  119. </dd>
  120. <dd class="">
  121. <a href="auxiliar.html" tppabs="http://www.layui.com/demo/auxiliar.html">辅助元素</a>
  122. </dd>
  123. </dl>
  124. </li>
  125. <li class="layui-nav-item layui-nav-itemed">
  126. <a class="javascript:;" href="javascript:;">组件示例</a>
  127. <dl class="layui-nav-child">
  128. <dd class="">
  129. <a href="layer.html" tppabs="http://www.layui.com/demo/layer.html">
  130. 弹出层
  131. </a>
  132. </dd>
  133. <dd class="">
  134. <a href="laydate.html" tppabs="http://www.layui.com/demo/laydate.html">
  135. 日期与时间选择
  136. </a>
  137. </dd>
  138. <dd class="">
  139. <a href="table.html" tppabs="http://www.layui.com/demo/table.html">
  140. 数据表格
  141. </a>
  142. </dd>
  143. <dd class="">
  144. <a href="laypage.html" tppabs="http://www.layui.com/demo/laypage.html">
  145. 分页
  146. </a>
  147. </dd>
  148. <dd class="">
  149. <a href="dropdown.html" tppabs="http://www.layui.com/demo/dropdown.html">
  150. 下拉菜单
  151. </a>
  152. </dd>
  153. <dd class="">
  154. <a href="upload.html" tppabs="http://www.layui.com/demo/upload.html">
  155. 文件上传
  156. </a>
  157. </dd>
  158. <dd class="">
  159. <a href="transfer.html" tppabs="http://www.layui.com/demo/transfer.html">
  160. 穿梭框
  161. </a>
  162. </dd>
  163. <dd class="">
  164. <a href="tree.html" tppabs="http://www.layui.com/demo/tree.html">
  165. 树形组件
  166. </a>
  167. </dd>
  168. <dd class="">
  169. <a href="colorpicker.html" tppabs="http://www.layui.com/demo/colorpicker.html">
  170. 颜色选择器
  171. </a>
  172. </dd>
  173. <dd class="layui-this">
  174. <a href="slider.html" tppabs="http://www.layui.com/demo/slider.html">
  175. 滑块
  176. </a>
  177. </dd>
  178. <dd class="">
  179. <a href="rate.html" tppabs="http://www.layui.com/demo/rate.html">
  180. 评分
  181. </a>
  182. </dd>
  183. <dd class="">
  184. <a href="carousel.html" tppabs="http://www.layui.com/demo/carousel.html">
  185. 轮播
  186. </a>
  187. </dd>
  188. <dd class="">
  189. <a href="laytpl.html" tppabs="http://www.layui.com/demo/laytpl.html">
  190. 模板引擎
  191. </a>
  192. </dd>
  193. <dd class="">
  194. <a href="layedit.html" tppabs="http://www.layui.com/demo/layedit.html">
  195. 富文本编辑器
  196. </a>
  197. </dd>
  198. <dd class="">
  199. <a href="flow.html" tppabs="http://www.layui.com/demo/flow.html">
  200. 流加载
  201. </a>
  202. </dd>
  203. <dd class="">
  204. <a href="util.html" tppabs="http://www.layui.com/demo/util.html">
  205. 工具模块
  206. </a>
  207. </dd>
  208. <dd class="">
  209. <a href="code.html" tppabs="http://www.layui.com/demo/code.html">
  210. 文本行修饰
  211. </a>
  212. </dd>
  213. </dl>
  214. </li>
  215. <li class="layui-nav-item" style="height: 30px; text-align: center"></li>
  216. </ul>
  217. </div>
  218. </div>
  219. <div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
  220. <ul class="layui-tab-title site-demo-title">
  221. <li class="layui-this">预览</li>
  222. <li>查看代码</li>
  223. <li>帮助</li>
  224. </ul>
  225. <div class="layui-body layui-tab-content site-demo site-demo-body">
  226. <div class="layui-tab-item layui-show">
  227. <div class="layui-main">
  228. <div id="LAY_preview">
  229. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  230. <legend>基本滑块</legend>
  231. </fieldset>
  232. <div id="slideTest1" class="demo-slider"></div>
  233. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  234. <legend>定义初始值</legend>
  235. </fieldset>
  236. <div id="slideTest2" class="demo-slider"></div>
  237. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  238. <legend>设置最大最小值</legend>
  239. </fieldset>
  240. <div id="slideTest3" class="demo-slider"></div>
  241. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  242. <legend>设置步长</legend>
  243. </fieldset>
  244. <div id="slideTest4" class="demo-slider"></div>
  245. <div id="slideTest5" class="demo-slider"></div>
  246. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  247. <legend>设置提示文本</legend>
  248. </fieldset>
  249. <div id="slideTest6" class="demo-slider"></div>
  250. <div id="slideTest7" class="demo-slider"></div>
  251. <div id="test-slider-tips1" style="position:relative; left: 30px; top: -20px;"></div>
  252. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  253. <legend>开启输入框</legend>
  254. </fieldset>
  255. <div id="slideTest8" class="demo-slider"></div>
  256. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  257. <legend>开启范围选择</legend>
  258. </fieldset>
  259. <div id="slideTest9" class="demo-slider"></div>
  260. <div id="test-slider-tips2" style="position:relative; left: 30px; margin-top: -10px;"></div>
  261. <div id="slideTest10" class="demo-slider"></div>
  262. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  263. <legend>垂直滑块</legend>
  264. </fieldset>
  265. <div id="slideTest11" style="margin: 45px 30px; display: inline-block;"></div>
  266. <div id="slideTest12" style="margin: 45px 30px; display: inline-block;"></div>
  267. <div id="slideTest13" style="margin: 45px 30px; display: inline-block;"></div>
  268. <div id="slideTest14" style="margin: 45px 30px; display: inline-block;"></div>
  269. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  270. <legend>自定义颜色</legend>
  271. </fieldset>
  272. <div id="slideTest15" class="demo-slider"></div>
  273. <div id="slideTest16" class="demo-slider"></div>
  274. <div id="slideTest17" class="demo-slider"></div>
  275. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  276. <legend>禁用滑块</legend>
  277. </fieldset>
  278. <div id="slideTest18" class="demo-slider"></div>
  279. </div>
  280. <blockquote class="layui-elem-quote" style="margin-top: 30px;">
  281. 更多我们未能呈现的示例,还有待您在阅读文档、以及不断使用的过程,去深入挖掘。
  282. </blockquote>
  283. <div style="margin: 15px 0 100px; padding-bottom: 100px;">
  284. </div>
  285. </div>
  286. </div>
  287. <div class="layui-tab-item">
  288. <textarea class="layui-border-box site-demo-text site-demo-code" id="LAY_democode" spellcheck="false" readonly>
  289. <!DOCTYPE html>
  290. <html>
  291. <head>
  292. <meta charset="utf-8">
  293. <title>镜像站@Layui</title>
  294. <meta name="renderer" content="webkit">
  295. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  296. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  297. <link rel="stylesheet" href="/public/layui/dist/css/layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css" media="all">
  298. <!-- 注意:如果你直接复制所有代码到本地,上述css路径需要改成你本地的 -->
  299. </head>
  300. </textarea>
  301. </div>
  302. <div class="layui-tab-item">
  303. <div class="layui-main">
  304. <p></p>
  305. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  306. <legend>相关</legend>
  307. </fieldset>
  308. <a class="layui-btn layui-btn-normal" href="../doc/modules/slider.html" tppabs="http://www.layui.com/doc/modules/slider.html" target="_blank">滑块文档</a>
  309. </div>
  310. </div>
  311. </div>
  312. </div>
  313. <div class="layui-footer footer footer-demo">
  314. <p>
  315. Copyright &copy; 2021 <a href="../index.html" tppabs="http://www.layui.com/">「本站仅为 layui 文档保留的镜像站点,与官方无关」</a> MIT Licensed</p>
  316. <p>
  317. <a href="../about/disclaimer.html" tppabs="http://www.layui.com/about/disclaimer.html" target="_blank">免责声明</a>
  318. <a href="../about/relatedlinks.html" tppabs="http://www.layui.com/about/relatedlinks.html" target="_blank">友链</a>
  319. <a href="javascript:;" site-event="weixinmp">公众号</a>
  320. </p>
  321. <div class="site-union">
  322. <p class="site-union-desc">
  323. <span>
  324. </span>
  325. </p>
  326. </div>
  327. </div>
  328. <script>
  329. window.global = {
  330. pageType: 'demo'
  331. ,preview: function(){
  332. var preview = document.getElementById('LAY_preview');
  333. return preview ? preview.innerHTML : '';
  334. }()
  335. };
  336. </script>
  337. <div class="site-tree-mobile layui-hide">
  338. <i class="layui-icon layui-icon-spread-left"></i>
  339. </div>
  340. <div class="site-mobile-shade"></div>
  341. <script src="/public/layui/dist/layui.js" tppabs="http://res.layui.com/layui/dist/layui.js?t=1632428048355" charset="utf-8"></script>
  342. <script>
  343. layui.config({
  344. base: '/public/static/lay/modules/layui/'
  345. ,version: '1632428048355'
  346. }).use('global');
  347. </script>
  348. </div>
  349. <div id="LAY_democodejs">
  350. <script>
  351. layui.use('slider', function(){
  352. var $ = layui.$
  353. ,slider = layui.slider;
  354. //默认滑块
  355. slider.render({
  356. elem: '#slideTest1'
  357. });
  358. //定义初始值
  359. slider.render({
  360. elem: '#slideTest2'
  361. ,value: 20 //初始值
  362. });
  363. //设置最大最小值
  364. slider.render({
  365. elem: '#slideTest3'
  366. ,min: 20 //最小值
  367. ,max: 50 //最大值
  368. });
  369. //设置步长
  370. slider.render({
  371. elem: '#slideTest4'
  372. ,step: 10 //步长
  373. });
  374. slider.render({
  375. elem: '#slideTest5'
  376. ,step: 10 //步长
  377. ,showstep: true //开启间隔点
  378. });
  379. //设置提示文本
  380. slider.render({
  381. elem: '#slideTest6'
  382. ,min: 20
  383. ,max: 1000
  384. ,setTips: function(value){ //自定义提示文本
  385. return value + 'GB';
  386. }
  387. });
  388. slider.render({
  389. elem: '#slideTest7'
  390. ,tips: false //关闭默认提示层
  391. ,change: function(value){
  392. $('#test-slider-tips1').html('当前数值:'+ value);
  393. }
  394. });
  395. //开启输入框
  396. slider.render({
  397. elem: '#slideTest8'
  398. ,input: true //输入框
  399. });
  400. //开启范围选择
  401. slider.render({
  402. elem: '#slideTest9'
  403. ,value: 40 //初始值
  404. ,range: true //范围选择
  405. ,change: function(vals){
  406. $('#test-slider-tips2').html('开始值:'+ vals[0] + '、结尾值:'+ vals[1]);
  407. }
  408. });
  409. slider.render({
  410. elem: '#slideTest10'
  411. ,value: [30, 60] //初始值
  412. ,range: true //范围选择
  413. });
  414. //垂直滑块
  415. slider.render({
  416. elem: '#slideTest11'
  417. ,type: 'vertical' //垂直滑块
  418. });
  419. slider.render({
  420. elem: '#slideTest12'
  421. ,value: 30
  422. ,type: 'vertical' //垂直滑块
  423. });
  424. slider.render({
  425. elem: '#slideTest13'
  426. ,value: 50
  427. ,range: true //范围选择
  428. ,type: 'vertical' //垂直滑块
  429. });
  430. slider.render({
  431. elem: '#slideTest14'
  432. ,value: 80
  433. ,input: true //输入框
  434. ,type: 'vertical' //垂直滑块
  435. });
  436. //自定义颜色
  437. slider.render({
  438. elem: '#slideTest15'
  439. ,theme: '#1E9FFF' //主题色
  440. });
  441. slider.render({
  442. elem: '#slideTest16'
  443. ,value: 50
  444. ,theme: '#5FB878' //主题色
  445. });
  446. slider.render({
  447. elem: '#slideTest17'
  448. ,value: [30, 70]
  449. ,range: true
  450. ,theme: '#FF5722' //主题色
  451. });
  452. //禁用滑块
  453. slider.render({
  454. elem: '#slideTest18'
  455. ,value: 35
  456. ,disabled: true //禁用滑块
  457. });
  458. });
  459. </script>
  460. </div>
  461. </body>
  462. </html>