Home > Article > Web Front-end > Introduction to the swiper plug-in and how to carousel images
1. First create a swiper operating environment. The files required are swiper.min.js and swiper.min.css files.
<!DOCTYPE html> <html> <head> ... <link rel="stylesheet" href="path/to/swiper.min.css?1.1.10"> </head> <body> ... </body>
3989f20b29ca3784489ad4a92ad594dd2cacc6d41bbb37262a98f745aa00fbf0
73a6ac4ed44ffec12cee46588e518a5e
2. Write HTML content.
<div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide">Slide 1</div> <div class="swiper-slide">Slide 2</div> <div class="swiper-slide">Slide 3</div> </div> <!-- 如果需要分页器 --> <div class="swiper-pagination"></div> </div>
3. You may want to define a size for Swiper, but of course not.
.swiper-container { width: 600px; height: 300px; }
4. Initialize Swiper: It is best to next to the 36cc49f0c466276486e50c850b7e4956 tag (function call)
3f1c4e4b6b16bbbd69b2ee476dc4f83a
var swiper=new Swiper(' .swiper-container',{
autoplay:1000,//Automatic rotation
AutoplayDisableOnInteraction:false,//Continue scrolling after sliding
loop:true,///Loop
pagination:'.swiper -pagination',//pagination
paginationClickable:true,//small dot click
spaceBetween:30,///picture gap
direction:"horizontal"//default horizontal vertical vertical
})
2cacc6d41bbb37262a98f745aa00fbf0 36cc49f0c466276486e50c850b7e4956
The above is the detailed content of Introduction to the swiper plug-in and how to carousel images. For more information, please follow other related articles on the PHP Chinese website!