swiper.js 響應式多圖輪播特效

swiper.js實現響應式的左右切換圖片案例展現佈局javascript

一、head引入css文件

<link type="text/css" rel="stylesheet" href="css/style.css">

二、head引入js文件

<script type="text/javascript" src="js/swiper.min.js"></script>

三、body引入HTML代碼

<div class="banner-box">
	<div class="banner-top"></div>
	<div class="banner-title">
		<h1>選擇一個漂亮的模板</h1>
	</div>
	<div class="banner-text">
		<p>別具一格的不只是風景,更是您的官方網站</p>
	</div>
	<div class="banner-top-one"></div>
	<div class="swiper-container">
		<div class="swiper-wrapper">
			<div class="swiper-slide swiper-slide-center none-effect">
				<a href="javascript:;">
					<img src="images/banner1.jpg" about="" title="">
				</a>
			</div>
			<div class="swiper-slide">
				<a href="javascript:;">
					<img src="images/banner2.jpg" about="" title="">
				</a>
			</div>
			<div class="swiper-slide">
				<a href="javascript:;">
					<img src="images/banner3.jpg" about="" title="">
				</a>
			</div>
			<div class="swiper-slide">
				<a href="javascript:;">
					<img src="images/banner4.jpg" about="" title="">
				</a>
			</div>
			<div class="swiper-slide">
				<a href="javascript:;">
					<img src="images/banner5.jpg" about="" title="">
				</a>
			</div>
			<div class="swiper-slide">
				<a href="javascript:;">
					<img src="images/banner6.jpg" about="" title="">
				</a>
			</div>
		</div>
		<div class="banner-arrow">
			<div class="swiper-button-prev"></div>
			<div class="swiper-button-next"></div>
		</div>
	</div>
	<div class="swiper-pagination"></div>

</div>
<div class="banner-button">
	<a href="javascript:;" class="do-btn banner-button-btn"> 更多模板  </a>
</div>

<script type="text/javascript">

	window.onload = function() {
		var swiper = new Swiper('.swiper-container',{
			autoplay: false, //是否自動滾動
			speed: 500,      //滾動速速
			autoplayDisableOnInteraction: true,
			loop: true,
			centeredSlides: true,
			slidesPerView: 3, //當前選中
			pagination: '.swiper-pagination',
			paginationClickable: true,
			prevButton: '.swiper-button-prev', // 左右切換
			nextButton: '.swiper-button-next', // 左右切換
			onInit: function(swiper) {
				swiper.slides[3].className = "swiper-slide swiper-slide-active"; //當前選中 狀態
			},
			breakpoints: {
				100: {
					slidesPerView: 0,
				}
			}
		});
	}

</script>更多關於swiper.js特效,請參考:https://www.swiper.com.cn/demo/
相關文章
相關標籤/搜索