index10.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>jQuery幻灯片插件Owl Carousel演示-随机显示_dowebok</title>
  6. <style>
  7. #owl-demo { width: 900px; margin-left: auto; margin-right: auto;}
  8. #owl-demo .item { margin: 5px; padding: 30px 0; font: 48px arial; text-align: center; color: #fff;}
  9. </style>
  10. <link href="css/owl.carousel.css" rel="stylesheet">
  11. <link href="css/owl.theme.css" rel="stylesheet">
  12. <script src="http://cdn.staticfile.org/jquery/1.8.3/jquery.min.js"></script>
  13. <script src="js/owl.carousel.js"></script>
  14. <script>
  15. $(function(){
  16. function random(owlSelector){
  17. owlSelector.children().sort(function(){
  18. return Math.round(Math.random()) - 0.5;
  19. }).each(function(){
  20. $(this).appendTo(owlSelector);
  21. });
  22. }
  23. $('#owl-demo').owlCarousel({
  24. beforeInit: function(elem){
  25. random(elem);
  26. }
  27. });
  28. });
  29. </script>
  30. </head>
  31. <body>
  32. <div class="menu">
  33. <p class="menuc">
  34. <span></span>
  35. <a href="./">1、默认</a>
  36. <a href="index2.html">2、单个</a>
  37. <a href="index3.html">3、自动播放</a>
  38. <a href="index4.html">4、显示上一张/下一张</a>
  39. <a href="index5.html">5、自适应高度</a>
  40. <a href="index6.html">6、延迟加载(Lazy Load)</a>
  41. <a href="index7.html">7、加载JSON</a>
  42. <a href="index8.html">8、自定义JSON</a>
  43. <a href="index9.html">9、进度条</a>
  44. <a class="cur" href="index10.html">10、随机显示</a>
  45. </p>
  46. </div>
  47. <div class="main">
  48. <div class="mianc">
  49. <h1>随机显示</h1>
  50. <!-- Demo -->
  51. <div id="owl-demo" class="owl-carousel">
  52. <div class="item orange">1</div>
  53. <div class="item darkCyan">2</div>
  54. <div class="item yellow">3</div>
  55. <div class="item forestGreen">4</div>
  56. <div class="item dodgerBlue">5</div>
  57. <div class="item skyBlue">6</div>
  58. <div class="item zombieGreen">7</div>
  59. <div class="item violet">8</div>
  60. <div class="item steelGray">9</div>
  61. <div class="item dodgerBlue">10</div>
  62. <div class="item darkCyan">11</div>
  63. <div class="item zombieGreen">12</div>
  64. <div class="item orange">13</div>
  65. <div class="item forestGreen">14</div>
  66. <div class="item skyBlue">15</div>
  67. <div class="item darkCyan">16</div>
  68. </div>
  69. <!-- Demo end -->
  70. <p class="explain">试试刷新页面,看看序号是否有变化。</p>
  71. <div class="code">
  72. <h3 class="h31 cur">JavaScript</h3>
  73. <div class="pre">
  74. <pre class="pre-show prettyprint linenums">$(function(){
  75. function random(owlSelector){
  76. owlSelector.children().sort(function(){
  77. return Math.round(Math.random()) - 0.5;
  78. }).each(function(){
  79. $(this).appendTo(owlSelector);
  80. });
  81. }
  82. $('#owl-demo').owlCarousel({
  83. beforeInit: function(elem){
  84. random(elem);
  85. }
  86. });
  87. });</pre>
  88. </div>
  89. <h3 class="h32">HTML</h3>
  90. <div class="pre">
  91. <pre class="pre-show prettyprint linenums">&lt;div id="owl-demo" class="owl-carousel"&gt;
  92. &lt;div class="item orange"&gt;1&lt;/div&gt;
  93. &lt;div class="item darkCyan"&gt;2&lt;/div&gt;
  94. &lt;div class="item yellow"&gt;3&lt;/div&gt;
  95. &lt;div class="item forestGreen"&gt;4&lt;/div&gt;
  96. &lt;div class="item dodgerBlue"&gt;5&lt;/div&gt;
  97. &lt;div class="item skyBlue"&gt;6&lt;/div&gt;
  98. &lt;div class="item zombieGreen"&gt;7&lt;/div&gt;
  99. &lt;div class="item violet"&gt;8&lt;/div&gt;
  100. &lt;div class="item steelGray"&gt;9&lt;/div&gt;
  101. &lt;div class="item dodgerBlue"&gt;10&lt;/div&gt;
  102. &lt;div class="item darkCyan"&gt;11&lt;/div&gt;
  103. &lt;div class="item zombieGreen"&gt;12&lt;/div&gt;
  104. &lt;div class="item orange"&gt;13&lt;/div&gt;
  105. &lt;div class="item forestGreen"&gt;14&lt;/div&gt;
  106. &lt;div class="item skyBlue"&gt;15&lt;/div&gt;
  107. &lt;div class="item darkCyan"&gt;16&lt;/div&gt;
  108. &lt;/div&gt;</pre>
  109. </div>
  110. <h3 class="h33">CSS</h3>
  111. <div class="pre">
  112. <pre class="pre-show prettyprint linenums">#owl-demo {
  113. width: 900px;
  114. margin-left: auto;
  115. margin-right: auto;
  116. }
  117. #owl-demo .item {
  118. margin: 5px;
  119. padding: 30px 0;
  120. font: 48px arial;
  121. text-align: center;
  122. color: #fff;
  123. }</pre>
  124. </div>
  125. </div>
  126. <p class="vad">
  127. <a href="http://www.dowebok.com/" target="_blank">dowebok.com</a>
  128. <a href="http://www.dowebok.com/93.html" target="_blank">说 明</a>
  129. <a href="http://www.dowebok.com/93.html" target="_blank">下 载</a>
  130. </p>
  131. </div>
  132. </div>
  133. <!-- 以下是统计及其他信息,与演示无关,不必理会 -->
  134. <style>
  135. * { margin: 0; padding: 0;}
  136. html, body { height: 100%; overflow: hidden;}
  137. body { font-family: Consolas,arial,"宋体";}
  138. .menu { position: absolute; left: 0; top: 0; width: 200px; height: 100%; background-color: #ccc; font-family: Consolas,arial,"宋体";}
  139. .menuc { height: 100%; overflow-x: hidden; overflow-y: auto;}
  140. .menu span { display: block; height: 100px;}
  141. .menu a { display: block; height: 40px; margin: 0 0 1px 2px; padding-left: 10px; line-height: 40px; font-size: 14px; color: #333; text-decoration: none;}
  142. .menu a:hover { background-color: #eee;}
  143. .menu .cur { color: #000; background-color: #fff !important;}
  144. .main { height: 100%; margin-left: 200px;}
  145. .mianc { position: relative; height: 100%; overflow-x: hidden; overflow-y: auto;}
  146. .main h1 { width: 900px; margin: 40px auto; font: 32px "Microsoft Yahei";}
  147. .explain, .dowebok-explain { margin-top: 20px; font-size: 14px; text-align: center; color: #f50;}
  148. .vad { margin: 50px 0 10px; font-family: Consolas,arial,宋体,sans-serif; text-align:center;}
  149. .vad a { display: inline-block; height: 36px; line-height: 36px; margin: 0 5px; padding: 0 50px; font-size: 14px; text-align:center; color:#eee; text-decoration: none; background-color: #222;}
  150. .vad a:hover { color: #fff; background-color: #000;}
  151. .thead { width: 728px; height: 90px; margin: 0 auto; border-bottom: 40px solid transparent;}
  152. .code { position: relative; margin-top: 100px; padding-top: 41px;}
  153. .code h3 { position: absolute; top: 0; z-index: 10; width: 100px; height: 40px; font: 16px/40px "Microsoft Yahei"; text-align: center; cursor: pointer;}
  154. .code .cur { border: 1px solid #f0f0f0; border-bottom: 1px solid #f8f8f8; background-color: #f8f8f8;}
  155. .code .h31 { left: 0;}
  156. .code .h32 { left: 102px;}
  157. .code .h33 { left: 204px;}
  158. .code .h34 { left: 306px;}
  159. .code { width: 900px; margin-left: auto; margin-right: auto;}
  160. pre { padding: 15px 0; border: 1px solid #f0f0f0; background-color: #f8f8f8;}
  161. .f-dn { display: none;}
  162. </style>
  163. <link href="http://xww-global.u.qiniudn.com/prettify.css" rel="stylesheet">
  164. <script src="http://xww-global.u.qiniudn.com/prettify.js"></script>
  165. <script>
  166. window.prettyPrint && prettyPrint();
  167. $('.code h3').not(':first').next().addClass('f-dn');
  168. $('.code h3').click(function(){
  169. $(this).addClass('cur').siblings('h3').removeClass('cur');
  170. $(this).next().removeClass('f-dn').siblings('.pre').addClass('f-dn');
  171. });
  172. </script>
  173. <style>
  174. .orange{ background: #ff8a3c;}
  175. .darkCyan{ background: #42bdc2;}
  176. .forestGreen{ background: #7fc242;}
  177. .yellow { background: #ffd800;}
  178. .dodgerBlue { background: #388bd1;}
  179. .skyBlue { background: #a1def8;}
  180. .zombieGreen { background: #3fbf79;}
  181. .violet { background: #db6ac5;}
  182. .yellowLight { background: #fee664;}
  183. .steelGray { background: #cad3d0;}
  184. </style>
  185. </body>
  186. </html>