欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Swiper实现轮播图效果

程序员文章站 2022-06-03 14:04:58
本文实例为大家分享了swiper实现轮播图效果的具体代码,供大家参考,具体内容如下

本文实例为大家分享了swiper实现轮播图效果的具体代码,供大家参考,具体内容如下

<!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="../dist/css/swiper.min.css" rel="external nofollow" > 
<!-- demo styles -->

 
<style>
html, body {
position: relative;
height: 100%;

}

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: 100%;


 
}

.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;
 
}
 
</style>

</head>

<body>


 
<!-- swiper -->
 
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">slide 1</div> 
<div class="swiper-slide">slide 2</div>
<div class="swiper-slide">slide 3</div>
<div class="swiper-slide">slide 4</div>
<div class="swiper-slide">slide 5</div> 
<div class="swiper-slide">slide 6</div>
<div class="swiper-slide">slide 7</div>
<div class="swiper-slide">slide 8</div>
<div class="swiper-slide">slide 9</div>
<div class="swiper-slide">slide 10</div>
</div>

<!-- add pagination -->


 
<div class="swiper-pagination"></div>
 
</div>

 
<!-- swiper js -->
<script src="../dist/js/swiper.min.js"></script>
<!-- initialize swiper -->
 
<script>
var swiper = new swiper('.swiper-container', {
//小白点
 
pagination: '.swiper-pagination',
 
paginationclickable: true
 
});
</script>
 
</body>
 
</html>

最后 别忘了再打这些东西之前要引swiper.css和swiper.js插件哦!

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。