<link rel="stylesheet" href="https://cdn.suoluomei.com/common/js2.0/swiper/v4.3.0/swiper.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<script src="https://cdn.suoluomei.com/common/js/jquery-2.1.4.min.js"></script>
<script src="https://cdn.suoluomei.com/common/js2.0/swiper/v4.3.0/swiper.min.js"></script>
<div class="srceem">
<!-- Swiper 轮播 -->
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide"><img class="lunboimg"
src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1307393608,1173558873&fm=26&gp=0.jpg">
</div>
<div class="swiper-slide"><img class="lunboimg"
src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2898658313,1685012492&fm=26&gp=0.jpg">
</div>
<div class="swiper-slide"><img class="lunboimg"
src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2970995881,3208967359&fm=26&gp=0.jpg">
</div>
<div class="swiper-slide"><img class="lunboimg"
src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3197429252,593291742&fm=26&gp=0.jpg">
</div>
</div>
<!-- 左右按钮 -->
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
<!-- 下方小圆点 -->
<div class="swiper-pagination"></div>
</div>
</div>
<!-- Swiper JS -->
<script src="https://cdn.suoluomei.com/common/js2.0/swiper/v4.3.0/swiper.min.js"></script>
<!-- Initialize Swiper -->
<script>
var swiper = new Swiper('.swiper-container', {
spaceBetween: 30,
loop: true,//实现无缝轮播
autoplay: {
delay: 2500,//每一次跳转的时间
disableOnInteraction: false,
},
pagination: {
el: '.swiper-pagination',
clickable: true,
},
//左右按钮
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
</script>
html,
body {
position: relative;
height: 100%;
background-color: #F1F1F5;
}
body {
margin: 0;
padding: 0;
}
.srceem {
width: 100%;
margin: 0;
}
.swiper-container {
width: 100%;
height: 12rem;
background-color: black;
display: flex;
}
.swiper-slide {
text-align: center;
/* 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;
z-index: 99;
}
.lunboimg {
width: 100%;
height: auto;
}
来源:CSDN
作者:hql1024
链接:https://blog.csdn.net/hql1024/article/details/103510469