<!DOCTYPE html>
<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;
400px;
height: 400px;
}
.swiper-slide {
400px;
height: 400px;
background: orange;
}
.swiper-father {
500px;
height: 400px;
border: 1px solid red;
position: relative;
}
</style>
</head>
<body>
<!-- 增加一个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原本的箭头放在这里 -->
<!-- <div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div> -->
</div>
<!-- 我们把swiper 的箭头放到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原本的箭头放在这里 -->
<!-- <div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div> -->
</div>
<!-- 我们把swiper 的箭头放到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>