.wrapper { width:500px; height:300px; margin:0 auto; background:#ddd; } .item img { width:100%; height:100%; } .my-swiper-btn { font-family:'iconfont'; width:25px; height:35px; position:absolute; top:50%; margin-top:-17px; background:rgba(0,0,0,.15); color:#fff; font-size:20px; font-weight:900; text-align:center; line-height:35px; cursor:pointer;font-family:"宋体"; } .my-swiper-btn:hover { background:rgba(0,0,0,.4) } .my-swiper-lbtn { left:-3px; border-top-right-radius:17.5px; border-bottom-right-radius:17.5px; } .my-swiper-rbtn { border-top-left-radius:17.5px; border-bottom-left-radius:17.5px; right:-3px; } .my-swiper-wrapper { position:relative; overflow:hidden; } .my-swiper-wrapper> ul { padding:0; margin:0; } .my-swiper-wrapper > ul >li { padding:0; margin:0; list-style:none; } .my-swiper-animate .my-swiper-content::after { content:''; display:block; clear:both; } .my-swiper-animate .my-swiper-item { float:left; } .my-swiper-fade .my-swiper-content { position:relative; } .my-swiper-fade .my-swiper-item { position:absolute; } .my-swiper-spots { position:absolute; bottom:0; padding:10px 20px; left:0; right:0; } .my-swiper-spots span { display:inline-block; width:10px; height:10px; border-radius:50%; background:#eee; margin:0 5px; } .my-swiper-spots span.my-swiper-current { background:skyblue; } .my-swiper-content { position:absolute; }
更新时间:2021-04-06 15:41:22
$('.wrapper').swiper({ // 定义父元素,元素就会添加到该元素内 width: 500, // 定义宽度 height: 400, // 定义高度 list: $('.item'), // 定义子元素,该元素会被添加到父元素内 times: 3000, // 定义轮播时间 showspots: true, // 轮播类型 fade淡入淡出/animate从左到右 type: 'fade', // 是否自动轮播,true/false isauto: true, // 左右按钮的状态 changebtnstatus: 'always', // 按钮是否显示 always默认显示/hide没有按钮/hover鼠标移入显示按钮 spotsposition: 'center' // 定义小圆点位置 left左边/center中间/right右边 })