企业级开发网页轮播图Swiper
几乎每个网页都会用到轮播图swiper,今天就‘2分钟企业级快速开发swiper’任意一种轮播图博客
轮播图效果:
1、首先打开网址
https://www.swiper.com.cn/
2、点击找到最近喜欢的轮播效果
3、点击新窗口打开
4、找到swiper.mini.css下载和swiper.mini.js右键下载
5、下载完后把网页基本的html拷贝进自己的网页中或者在文档内找基本使用方法里面的代码
6、然后把下载的swiper.mini.css和swiper.mini.js导入,路径换成自己下载的路径
就完成了一个快速且简单的轮播图了效果如下:
如果需要改变轮播的长度宽度,改上面的css就好了
完整代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>swiper</title>
</head>
<link rel="stylesheet" type="text/css" href="swiper.min.css"/>
<!-- 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 Arrows -->
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
</div>
<!-- Swiper JS -->
<script src="../swiper.min.js"></script>
<!-- Initialize Swiper -->
<script>
var swiper = new Swiper('.swiper-container', {
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
</script>
</body>
</html>