<! DOCTYPEhtml>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="Width = device - width, initial - scale = 1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>swiper</title>
<link href="https://cdn.bootcss.com/Swiper/4.3.0/css/swiper.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/Swiper/4.5.0/js/swiper.min.js"></script>
<style>
.swiper-container {
border: 1px solid red;
width: 400px;
height: 400px;
}
.swiper-slide {
width: 400px;
height: 400px;
background: orange;
}
.swiper-father {
width: 500px;
height: 400px;
border: 1px solid red;
position: relative;
}
</style>
</head>
<body>
<! -- add a package for father -->
<div class="swiper-father">
<div class="swiper-container swiper-container1">
<div class="swiper-wrapper">
<div class="swiper-slide">slide1</div>
<div class="swiper-slide">slide2</div>
<div class="swiper-slide">slide3</div>
</div>
<! -- Siwper's original arrow is placed here -->
<! -- <div class="swiper-button-prev"></div> <div class="swiper-button-next"></div> -->
</div>
<! -- Let's put the swiper arrow outside the swiper -->
<div class="swiper-button-prev swiper-button-prev1"></div>
<div class="swiper-button-next swiper-button-next1"></div>
</div>
<div class="swiper-father">
<div class="swiper-container swiper-container2">
<div class="swiper-wrapper">
<div class="swiper-slide">slide1</div>
<div class="swiper-slide">slide2</div>
<div class="swiper-slide">slide3</div>
</div>
<! -- Siwper's original arrow is placed here -->
<! -- <div class="swiper-button-prev"></div> <div class="swiper-button-next"></div> -->
</div>
<! -- Let's put the swiper arrow outside the swiper -->
<div class="swiper-button-prev swiper-button-prev2"></div>
<div class="swiper-button-next swiper-button-next2"></div>
</div>
<script>
var mySwiper = new Swiper('.swiper-container1', {
direction: 'horizontal'.loop: false.navigation: {
nextEl: '.swiper-button-next1'.prevEl: '.swiper-button-prev1',}});var mySwiper2 = new Swiper('.swiper-container2', {
direction: 'horizontal'.loop: false.navigation: {
nextEl: '.swiper-button-next2'.prevEl: '.swiper-button-prev2',}});</script>
</body>
</html>
Copy the code