swiper选项卡还可以左右滑动,最后一个直接跳转链接
整理分享:
<!DOCTYPE html>
<html lang="en"> <head>
<meta charset="utf-8">
<title>Swiper demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.0.0/css/swiper.min.css">
<style>
*{margin:0;padding:0}
body,html{ max-width: 640px; margin: 0 auto; background-color: #ebebeb;}
a{ text-decoration: none; color: #333 }
li{list-style:none}
.swiper_tab{ overflow: hidden; font-size: 18px; font-weight: 700; background-color: #fff; height: 40px; line-height: 40px; overflow: hidden; text-align: center;}
.swiper_ul_wrap{width: 86%; float: left;}
.swiper_ul{display:flex;width:100%;flex-direction:row;justify-content:center;align-items:center}
.swiper_ul li{display:flex;display:-webkit-flex;cursor:pointer;flex:1;flex-direction:row;justify-content:center;align-items:center; position: relative; padding:0 10px;}
.swiper_ul li:after{ content: ""; position: absolute; right: 1px; height:17px; width: 1px; background-color: #ebebeb }
.swiper_ul li.active span{position: relative; color: #e82e2e; }
.swiper_ul li.active span:before{ content: ""; position: absolute; left:0; bottom:0; width: 100%; height: 3px; background-color: #e82e2e }
.swiper_ul_last{width: 14%; float: left;}
.swiper-slide{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:20px}
.swiper-slide{height:1px} /* 随意指定一个height值即可 */
.swiper-slide-active { height:auto}
</style>
</head> <body>
<div class="swiper_tab_wrap" id="swiperTabWrap">
<div class="swiper_tab">
<div class="swiper_ul_wrap">
<ul class="swiper_ul">
<li class="active"><span>推荐</span></li>
<li><span>生肖</span></li>
<li><span>看相</span></li>
<li><span>风水</span></li>
<li><span>取名</span></li>
<li><span>八字</span></li>
</ul>
</div>
<a href="https://cs.fuyuandian.com" class="swiper_ul_last"><span>商城</span></a>
</div>
<div class="swiper-container" id="swiperTabCon">
<div class="swiper-wrapper">
<div class="swiper-slide">内容1</div>
<div class="swiper-slide">内容2</div>
<div class="swiper-slide">内容3</div>
<div class="swiper-slide">内容14</div>
<div class="swiper-slide">内容15</div>
<div class="swiper-slide">内容16</div>
</div>
</div>
</div>
<script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.0.0/js/swiper.min.js"></script>
<script type="text/javascript">
var swiper = new Swiper('#swiperTabCon', {
speed: 500,
on: {
slideChangeTransitionStart: function() { //swiper从当前slide开始过渡到另一个slide时执行
var index = swiper.activeIndex;
$('#swiperTabWrap ul li').removeClass('active').eq(index).addClass('active');
}
}
});
$('#swiperTabWrap ul li').on('click', function(e) {
e.preventDefault();
//得到当前索引
var i = $(this).index();
$('#swiperTabWrap ul li').removeClass('active').eq(i).addClass('active');
swiper.slideTo(i, 1000, false);
});
</script>
</body> </html>
效果如图:
参考swiper一些涉及的属性:
https://www.swiper.com.cn/api/event/91.html
https://www.swiper.com.cn/api/methods/109.html
swiper选项卡还可以左右滑动,最后一个直接跳转链接的更多相关文章
- TabTopAutoLayout【自定义顶部选项卡区域(带下划线)(动态选项卡数据且可滑动)】
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 自定义顶部选项卡布局LinearLayout类,实现带下划线且可滑动效果.[实际情况中建议使用RecyclerView] 备注:如果 ...
- TabTopAutoTextSizeLayout【自定义文字字号区域(动态选项卡数据且可滑动)】
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 自定义顶部选项卡布局LinearLayout类,实现可滑动效果.[实际情况中建议使用RecyclerView] 对<TabTo ...
- Android ViewPager实现Tabhost选项卡底部滑块动态滑动过渡
<Android ViewPager实现Tabhost选项卡底部滑块动态滑动过渡> 之前基于github上的第三方开源控件ViewPagerIndicator的UnderlinePa ...
- 笨重的mfc还在基于系统控件,熟练的mfc工程师还比不过学习Qt一个月的学生开发效率高(比较精彩,韦易笑)
作者:韦易笑链接:https://www.zhihu.com/question/29636221/answer/45102191来源:知乎著作权归作者所有,转载请联系作者获得授权. 更新:擦,本来只有 ...
- 利用WCF的双工通讯实现一个简单的心跳监控系统 z
利用WCF的双工通讯实现一个简单的心跳监控系统 http://www.cnblogs.com/zuowj/p/5761011.html 何为心跳监控系统? 故名思义,就是监控某个或某些个程序的运行状态 ...
- 笔记——malloc、free、不同数据类型操作、.pyc文件、python安装第三方包、验证一个网站的所有链接有效性
C — malloc( ) and free( ) C 语言中使用malloc( )函数申请的内存空间,为什么一定要使用free释放? **malloc()函数功能:是从堆区申请一段连续的空间,函数结 ...
- Struts2 从一个Action跳至另一个Action
Struts2 从一个Action跳至另一个Action 一.注解的 @Result(name=SUCCESS,type="chain", params={"actio ...
- 【原创】Android 从一个Activity跳转到另外一个Activity
Android四大组件activity使用,实现两个activity之间的跳转 基本流程:创建两个activity-将其中一个activity中组件作为事件源-通过组件事件的处理借助intent对象实 ...
- 分享一个在线生成微信跳转链接实现微信内跳转浏览器打开URL的工具
前言 现如今微信对第三方推广链接的审核是越来越严格了,域名在微信中分享转发经常会被拦截,一旦被拦截用户就只能复制链接手动打开浏览器粘贴才能访问,要不然就是换个域名再推,周而复始.无论是哪一种情况都会面 ...
随机推荐
- AcWing 850. Dijkstra求最短路 II 堆优化版 优先队列 稀疏图
//稀疏图 点和边差不多 #include <cstring> #include <iostream> #include <algorithm> #include ...
- InkWell容器 和 官方自带日期组件 和第三方 日期格式转换组件
带点击事件的容器 InkWell( child: Text('时间'), onTap: _showTimePicker,), Flutter 日期和时间戳 日期转化成时间戳: var now = ...
- Spring一些注解
spring @component的作用详细介绍 1.@controller 控制器(注入服务) 2.@service 服务(注入dao) 3.@repository dao(实现dao访问) 4.@ ...
- oracle 唯独测试视图
--建立用户分配权限 create user groper identified by groper / grant connect,resource to groper / grant create ...
- js把树形数据转成扁平数据
我就直接上代码了都是实际项目里面用到的 1.假设这个json就已经是树型结构数据了(如果不知道怎么实现树型结构数据请看我另一篇博客) var compressedArr=afcommon.treeDa ...
- [BPNN]BP神经网络实现
BP神经网络实现 以3层网络为例,Python实现: 1.代码框架 主要函数: Init函数:设定InputLayer nodes.HiddenLayer nodes.OutputLayer node ...
- ThreadLocal是什么?
早在JDK 1.2的版本中就提供Java.lang.ThreadLocal,ThreadLocal为解决多线程程序的并发问题提供了一种新的思路.使用这个工具类可以很简洁地编写出优美的多线程程序. 当使 ...
- 在HTML中实现两个div并排显示
在HTML中让两个div并排显示,通常情况下有三种实现方式,包括: (1)设置为行内样式,display:inline-block (2)设置float浮动 (3)设置position定位属性为abs ...
- RemoteView设置高度
刚开始内层LinearLayout直接用 android:layout_height="match_parent" <?xml version="1.0" ...
- pandas read excel or csv
import pandas as pd """pandas doc:df.dtypes 查看数据每column 数据类型 id int64x0 float64df.rei ...