swiper图片轮播

html:

  <div style="width:600px">
<div id="banner">  
  <div class="swiper-container">
    <div class="swiper-wrapper">
      <div class="swiper-slide">
		<img src="img/s01.jpg">
		<p style="margin-top:-55px;color:#fff;background:rgba(100,55,66,0.5)">阿斯蒂芬是否都是大</p>
	  </div>
      <div class="swiper-slide">
		<img src="img/s02.jpg">
		<p style="margin-top:-55px;">阿斯蒂芬是否都是大</p>
	  </div>
      <div class="swiper-slide">
		<img src="img/s03.jpg">
		<p style="margin-top:-55px;">阿斯蒂芬是否都是大</p>
	  </div>
      <div class="swiper-slide">
		<img src="img/s04.jpg">
		<p style="margin-top:-55px;">阿斯蒂芬是否都是大</p>
	  </div>
    </div>
  </div>
  <div class="swiper-pagination"></div>
</div>
</div>

css:

  <style>
    body {
      background: #eee;
      font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
      font-size: 14px;
      color:#000;
      margin: 0;
      padding: 0;
    }
	#banner{
		max-width:1200px;}
    .swiper-slide {
       width:auto;
    }
	.swiper-slide img{
		width:600px;
		height: 400px;
	}
	.swiper-slide p{
		width:600px;
		    z-index: 15000000;
    position: relative;
	}
	.swiper-pagination{
		position:relative;
		width:600px;}
	.swiper-pagination-bullet{
		width:25%;
		height:auto;
		background:none;}
	.swiper-pagination-bullet img{
		width:150px;}		
  </style>

js:

<script>
  window.onload = function() {
    var swiper = new Swiper('.swiper-container',{
			pagination: {
			    el: '.swiper-pagination',
		    	clickable: true,
			    renderBullet: function (index, className) {
			        return '<span class="' + className + '"><image src="img/s0' + ( index  + 1 ) + '.jpg"></span>';
		    	},
	       },
	});
  }
</script>

需要引用 swiper-4.2.2.min.css和swiper-4.2.2.min.js

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值