您好,登錄后才能下訂單哦!
小編給大家分享一下flexslider.js實現移動端輪播的示例分析,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
效果如下:
代碼如下:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>flexslider.js移動端輪播</title> <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"> <style> /* reset wap */ body,p,a,div,ol,ul,li,dl,dd,h2,h3,h4,h5,h6,h7,input,iframe,nav,header,footer { margin: 0; padding: 0; list-style: none; } body { font: 16px Microsoft YaHei, sans-serif; -webkit-tap-highlight-color: transparent; color: #2a2b2c; background: #fff; } *, *::before, *::after { outline: none; box-sizing: border-box; } a,img { text-decoration: none; display: block; color: #2a2b2c; border: 0; } .wrapper { width: 360px; margin: 100px auto; } .h2s { margin: 40px 10px 10px 10px; font: 20px Microsoft YaHei; } /* flexslider */ .flexslider { height: 180px; position: relative; background: #f5f5f5; overflow: hidden; } .flex-viewport { height: 100%; } .slides { height: 100%; position: relative; z-index: 1; } .slides li { height: 100%; } .slides li a { display: block; height: 100%; position: relative; } .flexslider li img { display: block; width: 100%; height: 100%; display: none; } .flex-control-nav { text-align: center; padding: 0 5px; position: absolute; right: 0; bottom: 3px; z-index: 2; } .flex-control-nav li { display: inline-block; width: 8px; height: 8px; margin: 0 3px; } .flex-control-nav a { display: block; height: 100%; line-height: 40px; overflow: hidden; border: 1px solid #fff; border-radius: 55%; } .flex-control-nav .flex-active { background: #fff; } .flexslider .ps1 { width: 100%; height: 25px; color: #fff; background: rgba(0,0,0,.5); padding: 0 50px 0 10px; font: 14px/27px Microsoft YaHei; text-align: left; display: block; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; position: absolute; bottom: 0; left: 0; } </style> </head> <body> <div class="wrapper"> <div class="flexslider"> <ul class="slides"> <li> <a href=""> <img src="http://ww2.sinaimg.cn/large/bea70753gw1f6fg9db318j21hc0m8n61.jpg" > <p class="ps1">圖片標題</p> </a> </li> <li> <a href=""> <img src="http://ww4.sinaimg.cn/large/bea70753gw1f6fg9e38eyj21hc0m8tht.jpg" > <p class="ps1">圖片標題</p> </a> </li> <li> <a href=""> <img src="http://ww4.sinaimg.cn/large/bea70753gw1f6fg9enyp1j21hc0m8465.jpg" > <p class="ps1">圖片標題</p> </a> </li> </ul> </div> </div> <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script src="http://cdn.bootcss.com/flexslider/2.6.2/jquery.flexslider.min.js"></script> <script> $(function () { $('.flexslider').flexslider({ directionNav: false, //是否顯示左右控制按鈕 controlNav: true, //是否顯示底部切換按鈕 pauseOnAction: false, //手動切換后是否繼續自動輪播,繼續(false),停止(true),默認true animation: 'slide', //淡入淡出(fade)或滑動(slide),默認fade slideshowSpeed: 5000, //自動輪播間隔時間(毫秒),默認5000ms animationSpeed: 150, //輪播效果切換時間,默認600ms direction: 'horizontal', //設置滑動方向:左右horizontal或者上下vertical,需設置animation: "slide",默認horizontal randomize: false, //是否隨機幻切換 animationLoop: true //是否循環滾動 }); setTimeout($('.flexslider img').fadeIn()); }); </script> </body> </html>
以上是“flexslider.js實現移動端輪播的示例分析”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。