Swiper2和Swiper3区别详解与兼容IE8/IE9

  最近项目一些网站项目想到用Swiper3来制作响应式,但是发现IE9都不兼容, 而swiper2版本又少一个breakpoints参数 做响应式脚本非常不方便,于是想到新版的浏览器用3  ,iE9和以下用2

很简单的一个列子就是垂直滑动

区别位置也只有一个

1
2
     mode:  'vertical'  //2版本垂直滑动
     direction:  'vertical' , //3版本垂直滑动

就是这个! 只要在

   var mySwiper = new Swiper('.swiper-container', {

}

里面同时加入这个,然后头部文件,用IE 和非IE 来判断即可。

1
2
3
4
5
6
7
8
<!--[if !IE]><!--> 
< link  rel = "stylesheet"  href = "st/css/swiper3.css" >
< script  src = "st/js/swiper3.js" ></ script >
<!--<![endif]-->
<!--[if IE]>
<link rel="stylesheet" href="st/css/swiper2.css">
<script src="st/js/swiper2.min.js"></script>
<![endif]-->

或者下面这样,上面那个IE8下回出来if什么东西

1
2
3
4
5
6
7
8
<!--[if !IE]><!--> 
< link  rel = "stylesheet"  href = "st/css/swiper3.css" >
< script  src = "st/js/swiper3.js" ></ script >
<!--<![endif]-->
<!--[if IE]>
<link rel="stylesheet" href="st/css/swiper2.css">
<script src="st/js/swiper2.min.js"></script>
<![endif]-->

 

接下来就是分析css了

1
2
3
4
5
6
7
8
swiper 3  的核心文件是
    .wrapper{ 
display : flex;  
   flex- direction : column;//垂直对齐
}
.swiper-slide{
     flex-shrink:  0 ; //
}

2就没什么好说的了,只要

1
2
3
wrapper{ position : relative ;}//这个一定要有,就是用 top 的属性来滚动的,没定位滚动不了
 
好了!就这样吧!上面的引入文件都是官方的文件, 自己去官网下载即可!

转载于:https://www.cnblogs.com/liyanyu520/p/9590061.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值