swiper实现兼容 ie8浏览器

声明:这里我用的是swiper2版本,上代码:
HTML代码:

1
2
3
3

css代码:(左右点击按钮图片可以自己定义,样式也可以自己调)

.mn-swiper{
    width: 1186px;
    height: 100%;
    position: initial !important;
}
.swiper-wrapper {
    -webkit-transition-timing-function: linear;    /*之前是ease-out*/
    -moz-transition-timing-function: linear;
    -ms-transition-timing-function: linear;
    -o-transition-timing-function: linear;
    transition-timing-function: linear;
    margin: 0 auto;
  }
.mn-swiper .swiper-slide a{
    width: 100%;
    height: 100%;
    display: block;
    overflow: hidden;
}
.mn-swiper .swiper-slide{
    width: 268px !important;
    height: 150px !important;
    background: #000000;
    opacity: 0.2;   
    border-radius: 4px;
    font-size: 24px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #FFFFFF;
    line-height: 24px;
    margin-top: 40px;
    margin-left: 26px;
}
/* 左侧点击按钮 */
.mn-swiper .swiper-button-prev{
    left: 0;
    background-image: url(../index/images/swiper-l.png);
}
/* 右侧点击按钮 */
.mn-swiper .swiper-button-next{
    right: 0;
    background-image: url(../index/images/swiper-r.png);
}
.mn-swiper .swiper-button-next, .mn-swiper .swiper-button-prev{
    width: 32px;
    height: 32px;
    background-repeat: no-repeat;
    background-size: cover;
    position: absolute;
    top: 50%;
}
.mn-swiper .swiper-wrapper{
    width: 100%;
    margin: 0 auto;

js代码:

 //轮播图
    var mySwiper = new Swiper('.mn-swiper', {
        autoplay: true,
        touchRatio:1,
        speed:3000,  //匀速时间
        loop : true,
        freeMode:true,  //设置为true则变为free模式
        slidesPerView:4,
        slidesPerGroup:1,
    })
   //--  如果需要前进后退按钮 --
    $('.arrow-left').click(function(){
        mySwiper.swipePrev();
    });
    $('.arrow-right').click(function(){
        mySwiper.swipeNext();
    });

插件css:swiper.min.css

/*
 * Swiper - Mobile Touch Slider CSS
 * http://www.idangero.us/sliders/swiper
 *
 * Vladimir Kharlampidi, The iDangero.us
 * http://www.idangero.us/
 * 
 * Copyright 2012-2013, Vladimir Kharlampidi
 * The iDangero.us
 * http://www.idangero.us
 *
 * Licensed under GPL & MIT
 *
*/

/* ===============================================================
Basic Swiper Styles 
================================================================*/
.swiper-container {
	margin:0 auto;
	overflow:hidden;
	-webkit-backface-visibility:hidden;
	-moz-backface-visibility:hidden;
	-ms-backface-visibility:hidden;
	-o-backface-visibility:hidden;
	backface-visibility:hidden;
	/* Fix of Webkit flickering */
	z-index:1;
}
.swiper-wrapper {
	position:relative;
	width:100%;
	-webkit-transition-property:-webkit-transform, left, top;
	-webkit-transition-duration:0s;
	-webkit-transform:translate3d(0px,0,0);
	-webkit-transition-timing-function:ease;
	
	-moz-transition-property:-moz-transform, left, top;
	-moz-transition-duration:0s;
	-moz-transform:translate3d(0px,0,0);
	-moz-transition-timing-function:ease;
	
	-o-transition-property:-o-transform, left, top;
	-o-transition-duration:0s;
	-o-transform:translate3d(0px,0,0);
	-o-transition-timing-function:ease;
	-o-transform:translate(0px,0px);
	
	-ms-transition-property:-ms-transform, left, top;
	-ms-transition-duration:0s;
	-ms-transform:translate3d(0px,0,0);
	-ms-transition-timing-function:ease;
	
	transition-property:transform, left, top;
	transition-duration:0s;
	transform:translate3d(0px,0,0);
	transition-timing-function:ease;
}
.swiper-free-mode > .swiper-wrapper {
	/* -webkit-transition-timing-function: ease-out;
	-moz-transition-timing-function: ease-out;
	-ms-transition-timing-function: ease-out;
	-o-transition-timing-function: ease-out;
	transition-timing-function: ease-out;
	margin: 0 auto; */
	-webkit-transition-timing-function: linear;    /*之前是ease-out*/
    -moz-transition-timing-function: linear;
    -ms-transition-timing-function: linear;
    -o-transition-timing-function: linear;
    transition-timing-function: linear;
    margin: 0 auto;
}
.swiper-slide {
	float: left;
}

/* IE10 Windows Phone 8 Fixes */
.swiper-wp8-horizontal {
	-ms-touch-action: pan-y;
}
.swiper-wp8-vertical {
	-ms-touch-action: pan-x;
}

/* ===============================================================
Your custom styles, here you need to specify container's and slide's
sizes, pagination, etc.
================================================================*/
.swiper-container {
	/* Specify Swiper's Size: */

	/*width:200px;
	height: 100px;*/
}
.swiper-slide {
	/* Specify Slides's Size: */
	
	/*width: 100%;
	height: 100%;*/
}
.swiper-slide-active {
	/* Specific active slide styling: */
	
}
.swiper-slide-visible {
	/* Specific visible slide styling: */	

}
/* ===============================================================
Pagination Styles
================================================================*/
.swiper-pagination-switch {
	/* Stylize pagination button: */	

}
.swiper-active-switch {
	/* Specific active button style: */	
	
}
.swiper-visible-switch {
	/* Specific visible button style: */	
	
}

插件js:由于js过长我就不在粘贴复制了,附上官方文档链接(可以自行去下载):https://2.swiper.com.cn/
以下是在IE8浏览器的样式图:
swiper实现兼容 ie8浏览器_第1张图片

你可能感兴趣的:(JavaScript,javascript,css,html,html5,css3)