(1)html :
<div class="module device">
<div class="swiper-container setCenter">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="notice">
<div class="title t_align">
<p class="font38 color000 margin_b20">标题1</p>
<p class="font24 color666">标题内容</p>
</div>
<img src="img/xy_ry_01.jpg">
</div>
</div>
<div class="swiper-slide">
<div class="notice">
<div class="title t_align">
<p class="font38 color000 margin_b20">标题2</p>
<p class="font24 color666">标题内容</p>
</div>
<img src="img/xy_ry_02.jpg">
</div>
</div>
<div class="swiper-slide">
<div class="notice">
<div class="title t_align">
<p class="font38 color000 margin_b20">标题3</p>
<p class="font24 color666">标题内容</p>
</div>
<img src="img/xy_ry_03.jpg">
</div>
</div>
</div>
</div>
<!--线-->
<div class="pagination setLine"></div>
</div>
(2)js 移动端自适应布局(这个是按iphone 6设计稿750屏幕 :【css样式使用rem单位,会自适应所有手机】)
(function(doc, win) {
var docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function() {
var clientWidth = docEl.clientWidth;
if(!clientWidth) return;
if(clientWidth >= 750) {
docEl.style.fontSize = '100px';
} else {
docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
}
};
if(!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
这是控制图片效果js : var mySwiper = new Swiper('.swiper-container',{
pagination: '.pagination', /*控制线*/
loop:true,
grabCursor: true,
paginationClickable: true
})
(3)css:
/*图片*/
*{padding: 0;margin: 0;}
body{height: 100%;font-family: Helvetica;}
/*移动端禁止图片长按和vivo手机点击img标签放大图片,禁止长按识别二维码或保存图片*/
img{ pointer-events: none;vertical-align: sub;}
.module .color000{color: #000000;}
.module .color666{color: #666666;}
.module .font38{font-size: 0.38rem;}
.module .font24{font-size: 0.24rem;}
.module .margin_b20{margin-bottom: 0.2rem;}
.module .t_align{text-align: center; padding: 1.04rem 0 0.58rem;}
.device .setCenter { height: 6.3rem;}
.device .setLine {text-align: center;width: 100%;padding:0 0 0.8rem;}/*线样式*/
.module .content{padding-bottom:0.50rem;}
.device .notice{margin: 0 0.32rem;} /*居中 包含在图片里面才不会出移位问题*/
/*线样式*/
.swiper-pagination-switch {
display: inline-block;
width: 0.8rem;
height:0.08rem;
background: #f2f2f2;
border: 1px solid #c0c0c0;
margin: 0 0.1rem;
cursor: pointer;
}
.swiper-active-switch {background: #00a4ff; border:1px solid #c0c0c0;}
【备注:swiper.js 和swiper.css 这里就不上传了,自己在网上百度下载哈】