forked from nolimits4web/swiper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe0153d
commit c065310
Showing
1 changed file
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Swiper demo</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"> | ||
|
||
<!-- Link Swiper's CSS --> | ||
<link rel="stylesheet" href="../build/css/swiper.min.css"> | ||
|
||
<!-- Demo styles --> | ||
<style> | ||
body { | ||
background: #eee; | ||
font-family: Helvetica Neue, Helvetica, Arial, sans-serif; | ||
font-size: 14px; | ||
color:#000; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
.swiper-container { | ||
width: 100%; | ||
height: 300px; | ||
margin: 20px auto; | ||
} | ||
.swiper-slide { | ||
text-align: center; | ||
font-size: 18px; | ||
background: #fff; | ||
|
||
/* Center slide text vertically */ | ||
display: -webkit-box; | ||
display: -ms-flexbox; | ||
display: -webkit-flex; | ||
display: flex; | ||
-webkit-box-pack: center; | ||
-ms-flex-pack: center; | ||
-webkit-justify-content: center; | ||
justify-content: center; | ||
-webkit-box-align: center; | ||
-ms-flex-align: center; | ||
-webkit-align-items: center; | ||
align-items: center; | ||
} | ||
.append-buttons { | ||
text-align: center; | ||
margin-top: 20px; | ||
} | ||
.append-buttons a { | ||
display: inline-block; | ||
border: 1px solid #007aff; | ||
color: #007aff; | ||
text-decoration: none; | ||
padding: 4px 10px; | ||
border-radius: 4px; | ||
margin: 0 10px; | ||
font-size: 13px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<!-- Swiper --> | ||
<div class="swiper-container"> | ||
<div class="swiper-wrapper"></div> | ||
<!-- Add Pagination --> | ||
<div class="swiper-pagination"></div> | ||
<!-- Add Arrows --> | ||
<div class="swiper-button-next"></div> | ||
<div class="swiper-button-prev"></div> | ||
</div> | ||
<p class="append-buttons"> | ||
<a href="#" class="slide-1">Slide 1</a> | ||
<a href="#" class="slide-300">Slide 300</a> | ||
<a href="#" class="slide-600">Slide 600</a> | ||
</p> | ||
<!-- Swiper JS --> | ||
<script src="../dist/js/swiper.min.js"></script> | ||
|
||
<!-- Initialize Swiper --> | ||
<script> | ||
var swiper = new Swiper('.swiper-container', { | ||
slidesPerView: 3, | ||
centeredSlides: true, | ||
spaceBetween: 30, | ||
pagination: { | ||
el: '.swiper-pagination', | ||
type: 'fraction', | ||
}, | ||
navigation: { | ||
nextEl: '.swiper-button-next', | ||
prevEl: '.swiper-button-prev', | ||
}, | ||
virtual: { | ||
enabled: true, | ||
slides: (function () { | ||
var slides = []; | ||
for (var i = 0; i < 600; i += 1) { | ||
slides.push('Slide ' + (i + 1)); | ||
} | ||
return slides; | ||
}()), | ||
}, | ||
}); | ||
document.querySelector('.slide-1').addEventListener('click', function (e) { | ||
e.preventDefault(); | ||
swiper.slideTo(0, 0); | ||
}); | ||
document.querySelector('.slide-300').addEventListener('click', function (e) { | ||
e.preventDefault(); | ||
swiper.slideTo(299, 0); | ||
}); | ||
document.querySelector('.slide-600').addEventListener('click', function (e) { | ||
e.preventDefault(); | ||
swiper.slideTo(599, 0); | ||
}); | ||
</script> | ||
</body> | ||
</html> |