swiper 一组显示5张且点击左右按钮移动一张图片,选中的当前项有放大效果

1.dom元素

2.css样式

// 引入swiper.min.css


#box{
  width: 1324px;  
  margin: 20px auto;    
}
.swiper-container {
  width: 100%;
// 下面的padding 一定要加 (因为容器多余的部分被隐藏啦)
  padding-top: 50px;
  padding-bottom: 50px;
}
.swiper-slide {
  width: 261px;
  height: 162px;
  background-position: center;
  background-size: cover;
  transition: all 1s;

  /* 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;
 
}
.swiper-slide img{
  width: 100%;
}
// 激活的样式(选中的当前项)	
.swiper-slide.swiper-slide-active{	
  transform: scale(1.2);
  z-index: 2;

}

3.js代码

// 引入swiper.min.js



 

你可能感兴趣的:(swiper)