swiper 应用
- swiper之PC端的广告页面【当前示例对应网站:http://shang.shuaishou.com/】
plugins:【红线部分】
html:
<div class="banner swiper-container">
<ul class="list-none swiper-wrapper">
<li class="swiper-slide"><a href="#"><img src="../img/index/banner1.png"></a></li>
<li class="swiper-slide"><a href="#"><img src="../img/index/banner1.png"></a></li>
<li class="swiper-slide"><a href="#"><img src="../img/index/banner1.png"></a></li>
</ul>
<!-- 如果需要分页器 -->
<div class="pagination"></div>
<!-- 如果需要导航按钮 -->
<a class="arrow arrow-left" href="javascript:void(0)"></a>
<a class="arrow arrow-right" href="javascript:void(0)"></a>
</div>
css:
@mixin transition($property:all,$time:.5s,$func:linear){
-webkit-transition: $property $time $func;
-moz-transition: $property $time $func;
-ms-transition: $property $time $func;
-o-transition: $property $time $func;
transition: $property $time $func;
}
.swiper-pagination-switch {
display: inline-block;
width: 8px;
height: 8px;
background: #fff;
margin: 0 5px;
cursor: pointer;
opacity: .8;
@include transition(height,.5s);
}
.swiper-active-switch {
height:20px;
opacity:;
}
.swiper-container .pagination {
position: absolute;
margin:;
z-index:;
right:5px;
bottom: 10px;
width: 100%;
text-align: right;
}
.swiper-container{
width:100%;
height:auto;
}
.swiper-container .arrow-left{
left:50px;
}
.swiper-container .arrow-right{
right: 50px;
background-position: -50px 0;
}
.swiper-container .arrow-left,.swiper-container .arrow-right{
display:none;
background-image: url(../img/indexSlideArrow.png);
background-repeat: no-repeat;
background-size: 260%;
position: absolute;
top: 50%;
margin-top: -25px;
width: 30px;
height: 50px;
z-index:;
}
javascript:
(function(w,$){
var indexObj = {
init:function(){
indexObj.swiperInit();
},
swiperInit:function(){
var _siwper = ".index .swiper-container";
var swiper = new Swiper(_siwper, {
autoplay:3000,
speed:400,
mode: 'horizontal',
loop: true,
calculateHeight: true,//自动高度
// 如果需要分页器
pagination: '.index .pagination',
paginationClickable:true
});
var $swiper = $(_siwper),
$arrow = $swiper.find('.arrow');
$swiper.on("mouseenter",function(){
swiper.stopAutoplay();
$arrow.addClass("active");
});
$swiper.on("mouseleave",function(){
swiper.startAutoplay();
$arrow.removeClass("active");
});
$swiper.find('.arrow-left').click(function(){
swiper.swipePrev();
});
$swiper.find('.arrow-right').click(function(){
swiper.swipeNext();
});
}
};
$(indexObj.init);
})(window,jQuery);
页面效果:
swiper之移动端tab切换
plugins:导入swiper4版本
html:
<link href="https://cdn.bootcss.com/Swiper/4.2.2/css/swiper.min.css" rel="stylesheet"> <div class="swiper-container" id="selectBanner">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="banner-img">
<img src="../imgs/banner.jpg">
<span class="bi-time bg-red">2018-01-20下午2点</span>
<p class="bi-text">
<span class="ci-t">0基础打包爆款!200人已报名</span>
<a href="#" class="bg-red">立即报名</a>
</p>
</div>
</div>
<div class="swiper-slide">
<div class="banner-img">
<img src="../imgs/banner.jpg">
<span class="bi-time bg-red">2018-01-20下午2点</span>
<p class="bi-text">
<span class="ci-t">0基础打包爆款!200人已报名</span>
<a href="#" class="bg-red">立即报名</a>
</p>
</div>
</div>
</div>
<!--<!– 如果需要分页器 –>-->
<div class="swiper-pagination"></div>
</div>
scss:
.select-tab{
background-color: #fff;
height:1rem;
line-height: .96rem;
text-align: center;
@include ul-reset();
.border-bottom{
&:after{
@include position($bottom:0.08rem,$left:-70%);
content:"";
width:70%;
height:3px;
background-color: $theme;
//@include transition(left);
}
}
li,.swiper-pagination-bullet{
display:inline-block;
width:50%;
height:100%;
float:left;
@include radius(0);
margin:;
background: #fff;
opacity:;
&.active{
a{
@include color-link($theme,$theme);
&:after{
left:15%;
}
}
}
}
a{
display:inline-block;
position: relative;
overflow: hidden;
@include color-link();
@extend .border-bottom;
}
.swiper-pagination-bullet{
i{
position:relative;
display:inline-block;
overflow: hidden;
@extend .border-bottom;
}
}
}
.tab{
&.detail{
background-color: $bg;
&.swiper-container-horizontal{
height:auto;
padding-top: 1.533326rem;
}
.swiper-wrapper{
background-color: #fff;
}
.swiper-pagination-bullets{
top:.266666rem;
}
}
&.swiper-container-horizontal{
height:100%;
padding-top: 1.266667rem;
}
.swiper-pagination-bullets{
bottom:auto;
top:;
left:;
width:100%;
@extend .select-tab;
.swiper-pagination-bullet-active{
background-color: #fff;
color:$theme;
i:after{
left:15%;
}
}
}
.swiper-wrapper .swiper-slide{
overflow-x: hidden;
overflow-y: auto;
overflow-scrolling: touch;
}
}
@keyframes border-move {
0%{
left:-70%;
}
100%{
left:15%;
}
}
@-webkit-keyframes border-move{
0%{
left:-70%;
}
100%{
left:15%;
}
}
.swiper-container-horizontal{
.swiper-pagination-bullets{
bottom:.8rem;
}
}
.swiper-pagination-bullet-active{
background-color: $theme;
}
javascript:
<script src="https://cdn.bootcss.com/Swiper/4.2.2/js/swiper.min.js"></script>
<script src="https://cdn.bootcss.com/zepto/1.2.0/zepto.min.js"></script> (function(){
var mySwiper = new Swiper ('#selectCon', {
pagination: {
el: '.swiper-pagination',
clickable: true,
renderBullet: function (index, className) {
var text;
switch (index) {
case 0:
text = '详情课程';
break;
case 1:
text = '课程大纲';
break;
}
return '<span class="' + className + '" style="opacity:1;"><i>' + text + '</i></span>'
}
}
});
})();
效果:
swiper 应用的更多相关文章
- swiper插件 纵向内容超出一屏解决办法
1.css .swiper-slide { overflow: auto; } 2.js var swiper = new Swiper('.swiper-container', { directio ...
- swiper的初步使用
1.引入文件,顺序引入(此处基于jquery,且版本至少1.7以上) <link rel="stylesheet" href="path/to/swiper-3.4 ...
- 关于移动端swiper的2种样式重置
手机查看效果地址:猛戳 ,PC端查看可以缩放浏览器窗口看效果~~ 思路:主要考虑选择器优先级大于默认就可以随意撸码 注意:该demo里用的mobile-adaptive.js是让页面以rem自适应,也 ...
- ReactNative新手学习之路04 组件化开发轮播图swiper支持安卓和IOS
react native 新手之路04 组件化开发轮播图swiper支持安卓和IOS npm install react-native-carousel --save git 地址Properties ...
- swiper框架,实现轮播图等滑动效果
http://www.swiper.com.cn/ 做个记录而已,这个没什么好说的,对于需要手机端开发实现触摸等方式可以看看.
- swiper.animate~之~可以执行两种动画的升级版的Swiper Animate
1.下载插件swiper.animate-twice.min.js,加载进页面. <!DOCTYPE html> <html> <head> ... < ...
- swiper横向轮播--3d
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- swiper横向轮播(兼容IE8)
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- Swiper说明&&API手册 【中文手册Swiper】
原文地址:http://www.cnblogs.com/scavengers/p/3760449.html 示例: <link rel="stylesheet" href= ...
- Swiper 中文API手册(share)
本文分享自 http://www.cnblogs.com/scavengers/p/3760449.html ---------------------------华丽的分割线------------ ...
随机推荐
- linux --> 获取系统启动时间
获取系统启动时间 一.前言 时间对操作系统来说非常重要,从内核级到应用层,时间的表达方式及精度各部相同.linux内核里面用一个名为jiffes的常量来计算时间戳.应用层有time.getdaytim ...
- DB2开发系列之三——SQL函数
1.内置函数分类(SYSIBM模式内) 1)标量函数:返回一个标量值的函数: 2)聚合函数:也叫列函数,也返回一个标量值,这个值是一组输入值的计算结果:3)表函数:向引用它的 SQL 语句返回一个表: ...
- 解决设置clickablespan后长按冲突的问题
解决设置ClickableSpan后长按冲突的问题 问题描述 3月份修改别人代码的时候想要屏蔽TextView的长按事件,发现TextView有重写OnTouchEvent方法,然后在其中加了长按事件 ...
- 云服务器Windows Server2012 配置http服务器(又称Web服务器,IIS)
出错:无法打开运行空间池.服务器管理器WinRM插件可能已损坏或丢失. 解决方法: http://shiyousan.com/post/636308065767125916 第一步是开启WinRM服务 ...
- p-value
p-value p-value翻译为假定值,假设几率.我们在生物信息中通常使用p值方法(P-Value, Probability, Pr)来做检验.那么p-value是什么呢?其实P-value就是一 ...
- c语言最后一次作业
1.当初你是如何做出选择计算机专业的决定的? 我再来到大学之前,通过查询和询问,了解到当前计算机行业就业需求量较高,同时我对计算机的几年过去比较高了,在高中时期就有过在大学学习计算机行业的知识与专业的 ...
- 【alpha冲刺】随笔合集
Daily Scrum Meeting 第一天 [Alpha]Daily Scrum Meeting第一次 第二天 [Alpha]Daily Scrum Meeting第二次 第三天 [Alpha]D ...
- C语言第十一次博客作业---函数嵌套调用
一.实验作业 1.1 PTA题目 题目:递归实现顺序输出整数 1. 本题PTA提交列表 2. 设计思路 printdigits函数 定义整型变量result存放结果 if n是10的倍数 result ...
- C语言博客作业-结构体
一.PTA实验作业 6-2 按等级统计学生成绩 1. 本题PTA提交列表 2. 设计思路 定义i,count存放不及格人数 for i=0 to n-1{ 判断 score的值的范围 if 100&g ...
- Alpha冲刺No.6
站立式会议 继续页面设计 在安卓内构件数据库相应类 解决摄像头.照片的使用的异常问题 二.实际项目进展 页面设计完成百分80 类架构完成 在虚拟机中,能够完成摄像头的调用和程序的使用 三.燃尽图 四. ...