index7.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>jQuery幻灯片插件Owl Carousel演示-加载JSON_dowebok</title>
  6. <style>
  7. #owl-demo { width: 900px; margin-left: auto; margin-right: auto;}
  8. #owl-demo .item{ display: block; margin: 5px;}
  9. #owl-demo img { display: block; width: 100%;}
  10. </style>
  11. <link href="css/owl.carousel.css" rel="stylesheet">
  12. <link href="css/owl.theme.css" rel="stylesheet">
  13. <script src="http://cdn.staticfile.org/jquery/1.8.3/jquery.min.js"></script>
  14. <script src="js/owl.carousel.js"></script>
  15. <script>
  16. $(function(){
  17. $('#owl-demo').owlCarousel({
  18. jsonPath: 'json/data.json'
  19. });
  20. });
  21. </script>
  22. </head>
  23. <body>
  24. <div class="menu">
  25. <p class="menuc">
  26. <span></span>
  27. <a href="./">1、默认</a>
  28. <a href="index2.html">2、单个</a>
  29. <a href="index3.html">3、自动播放</a>
  30. <a href="index4.html">4、显示上一张/下一张</a>
  31. <a href="index5.html">5、自适应高度</a>
  32. <a href="index6.html">6、延迟加载(Lazy Load)</a>
  33. <a class="cur" href="index7.html">7、加载JSON</a>
  34. <a href="index8.html">8、自定义JSON</a>
  35. <a href="index9.html">9、进度条</a>
  36. <a href="index10.html">10、随机显示</a>
  37. </p>
  38. </div>
  39. <div class="main">
  40. <div class="mianc">
  41. <h1>加载JSON</h1>
  42. <!-- Demo -->
  43. <div id="owl-demo" class="owl-carousel">
  44. </div>
  45. <!-- Demo end -->
  46. <div class="code">
  47. <h3 class="h31 cur">JavaScript</h3>
  48. <div class="pre">
  49. <pre class="pre-show prettyprint linenums">$(function(){
  50. $('#owl-demo').owlCarousel({
  51. jsonPath: 'json/data.json'
  52. });
  53. });</pre>
  54. </div>
  55. <h3 class="h32">JSON</h3>
  56. <div class="pre">
  57. <pre class="pre-show prettyprint linenums">{
  58. "owl" : [
  59. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl1.jpg' alt=''&gt;&lt;/a&gt;"},
  60. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl2.jpg' alt=''&gt;&lt;/a&gt;"},
  61. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl3.jpg' alt=''&gt;&lt;/a&gt;"},
  62. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl4.jpg' alt=''&gt;&lt;/a&gt;"},
  63. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl5.jpg' alt=''&gt;&lt;/a&gt;"},
  64. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl6.jpg' alt=''&gt;&lt;/a&gt;"},
  65. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl7.jpg' alt=''&gt;&lt;/a&gt;"},
  66. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl8.jpg' alt=''&gt;&lt;/a&gt;"},
  67. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl1.jpg' alt=''&gt;&lt;/a&gt;"},
  68. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl2.jpg' alt=''&gt;&lt;/a&gt;"},
  69. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl3.jpg' alt=''&gt;&lt;/a&gt;"},
  70. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl4.jpg' alt=''&gt;&lt;/a&gt;"},
  71. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl5.jpg' alt=''&gt;&lt;/a&gt;"},
  72. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl6.jpg' alt=''&gt;&lt;/a&gt;"},
  73. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl7.jpg' alt=''&gt;&lt;/a&gt;"},
  74. {"item" : "&lt;a class='item'&gt;&lt;img src='img/owl8.jpg' alt=''&gt;&lt;/a&gt;"}
  75. ]
  76. }</pre>
  77. </div>
  78. <h3 class="h33">HTML</h3>
  79. <div class="pre">
  80. <pre class="pre-show prettyprint linenums">&lt;div id="owl-demo" class="owl-carousel"&gt;
  81. &lt;/div&gt;</pre>
  82. </div>
  83. <h3 class="h34">CSS</h3>
  84. <div class="pre">
  85. <pre class="pre-show prettyprint linenums">#owl-demo {
  86. width: 900px;
  87. margin-left: auto;
  88. margin-right: auto;
  89. }
  90. #owl-demo .item {
  91. display: block;
  92. margin: 5px;
  93. }
  94. #owl-demo img {
  95. display: block;
  96. width: 100%;
  97. }</pre>
  98. </div>
  99. </div>
  100. <p class="vad">
  101. <a href="http://www.dowebok.com/" target="_blank">dowebok.com</a>
  102. <a href="http://www.dowebok.com/93.html" target="_blank">说 明</a>
  103. <a href="http://www.dowebok.com/93.html" target="_blank">下 载</a>
  104. </p>
  105. </div>
  106. </div>
  107. <!-- 以下是统计及其他信息,与演示无关,不必理会 -->
  108. <style>
  109. * { margin: 0; padding: 0;}
  110. html, body { height: 100%; overflow: hidden;}
  111. body { font-family: Consolas,arial,"宋体";}
  112. .menu { position: absolute; left: 0; top: 0; width: 200px; height: 100%; background-color: #ccc; font-family: Consolas,arial,"宋体";}
  113. .menuc { height: 100%; overflow-x: hidden; overflow-y: auto;}
  114. .menu span { display: block; height: 100px;}
  115. .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;}
  116. .menu a:hover { background-color: #eee;}
  117. .menu .cur { color: #000; background-color: #fff !important;}
  118. .main { height: 100%; margin-left: 200px;}
  119. .mianc { position: relative; height: 100%; overflow-x: hidden; overflow-y: auto;}
  120. .main h1 { width: 900px; margin: 40px auto; font: 32px "Microsoft Yahei";}
  121. .explain, .dowebok-explain { margin-top: 20px; font-size: 14px; text-align: center; color: #f50;}
  122. .vad { margin: 50px 0 10px; font-family: Consolas,arial,宋体,sans-serif; text-align:center;}
  123. .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;}
  124. .vad a:hover { color: #fff; background-color: #000;}
  125. .thead { width: 728px; height: 90px; margin: 0 auto; border-bottom: 40px solid transparent;}
  126. .code { position: relative; margin-top: 100px; padding-top: 41px;}
  127. .code h3 { position: absolute; top: 0; z-index: 10; width: 100px; height: 40px; font: 16px/40px "Microsoft Yahei"; text-align: center; cursor: pointer;}
  128. .code .cur { border: 1px solid #f0f0f0; border-bottom: 1px solid #f8f8f8; background-color: #f8f8f8;}
  129. .code .h31 { left: 0;}
  130. .code .h32 { left: 102px;}
  131. .code .h33 { left: 204px;}
  132. .code .h34 { left: 306px;}
  133. .code { width: 900px; margin-left: auto; margin-right: auto;}
  134. pre { padding: 15px 0; border: 1px solid #f0f0f0; background-color: #f8f8f8;}
  135. .f-dn { display: none;}
  136. </style>
  137. <link href="http://xww-global.u.qiniudn.com/prettify.css" rel="stylesheet">
  138. <script src="http://xww-global.u.qiniudn.com/prettify.js"></script>
  139. <script>
  140. window.prettyPrint && prettyPrint();
  141. $('.code h3').not(':first').next().addClass('f-dn');
  142. $('.code h3').click(function(){
  143. $(this).addClass('cur').siblings('h3').removeClass('cur');
  144. $(this).next().removeClass('f-dn').siblings('.pre').addClass('f-dn');
  145. });
  146. </script>
  147. </body>
  148. </html>