整理分享:

<!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选项卡还可以左右滑动,最后一个直接跳转链接的更多相关文章

  1. TabTopAutoLayout【自定义顶部选项卡区域(带下划线)(动态选项卡数据且可滑动)】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 自定义顶部选项卡布局LinearLayout类,实现带下划线且可滑动效果.[实际情况中建议使用RecyclerView] 备注:如果 ...

  2. TabTopAutoTextSizeLayout【自定义文字字号区域(动态选项卡数据且可滑动)】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 自定义顶部选项卡布局LinearLayout类,实现可滑动效果.[实际情况中建议使用RecyclerView] 对<TabTo ...

  3. Android ViewPager实现Tabhost选项卡底部滑块动态滑动过渡

     <Android ViewPager实现Tabhost选项卡底部滑块动态滑动过渡> 之前基于github上的第三方开源控件ViewPagerIndicator的UnderlinePa ...

  4. 笨重的mfc还在基于系统控件,熟练的mfc工程师还比不过学习Qt一个月的学生开发效率高(比较精彩,韦易笑)

    作者:韦易笑链接:https://www.zhihu.com/question/29636221/answer/45102191来源:知乎著作权归作者所有,转载请联系作者获得授权. 更新:擦,本来只有 ...

  5. 利用WCF的双工通讯实现一个简单的心跳监控系统 z

    利用WCF的双工通讯实现一个简单的心跳监控系统 http://www.cnblogs.com/zuowj/p/5761011.html 何为心跳监控系统? 故名思义,就是监控某个或某些个程序的运行状态 ...

  6. 笔记——malloc、free、不同数据类型操作、.pyc文件、python安装第三方包、验证一个网站的所有链接有效性

    C — malloc( ) and free( ) C 语言中使用malloc( )函数申请的内存空间,为什么一定要使用free释放? **malloc()函数功能:是从堆区申请一段连续的空间,函数结 ...

  7. Struts2 从一个Action跳至另一个Action

    Struts2  从一个Action跳至另一个Action 一.注解的 @Result(name=SUCCESS,type="chain", params={"actio ...

  8. 【原创】Android 从一个Activity跳转到另外一个Activity

    Android四大组件activity使用,实现两个activity之间的跳转 基本流程:创建两个activity-将其中一个activity中组件作为事件源-通过组件事件的处理借助intent对象实 ...

  9. 分享一个在线生成微信跳转链接实现微信内跳转浏览器打开URL的工具

    前言 现如今微信对第三方推广链接的审核是越来越严格了,域名在微信中分享转发经常会被拦截,一旦被拦截用户就只能复制链接手动打开浏览器粘贴才能访问,要不然就是换个域名再推,周而复始.无论是哪一种情况都会面 ...

随机推荐

  1. Java - 集合 - 定义和分类

    Java集合框架主要包括两种类型的容器:Collection和Map   层级结构图:evernote:///view/27699174/s49/d9aaf84e-e218-40a0-89c1-358 ...

  2. CDH的坑之Deploy Client Configuration Failed

    Deploy Client Configuration Failed 1.问题描述 当使用CDH增添spark服务的时候,出现了以下错误: Faile to deploy client configu ...

  3. 【 Struts2 配置】Struts2基本搭建

    struts.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBL ...

  4. PHP通过thrift2访问HBASE

    前一段时间需要在网页上显示HBASE查询的结果,考虑用PHP来实现,在网上搜了一下,普遍都是用thrift作为接口来实现的.​ 参考博文:​ http://www.cnblogs.com/scotom ...

  5. Kali部署DVWA和OWASPBWA

    自己的备忘录,这里记录Kali部署DVWA和OWASPBWA,其中遇到的问题会在下一篇文章记录 DVWA(Damn Vulnerable Web App)是一个基于PHP/MySql搭建的Web应用程 ...

  6. Kali2.0中peda与pwntools的安装

    MarkdownPad Document *:first-child { margin-top: 0 !important; } body>*:last-child { margin-botto ...

  7. 刷题10. Regular Expression Matching

    一.题目说明 这个题目是10. Regular Expression Matching,乍一看不是很难. 但我实现提交后,总是报错.不得已查看了答案. 二.我的做法 我的实现,最大的问题在于对.*的处 ...

  8. (原创)SoapUI学习(2)- POST请求

    1.新建Project,右键Projects->New REST Project,可以不填直接点击OK,之后通过rename重命名.(如果这里添加URL,则直接达到第三步的图) 2.右键新建的工 ...

  9. cs/bs

    c(客户端)/s服务器:使用前必须安装,更新是,c s同时更新,不能跨频繁太,采用自由协议,相对来说安全. b(浏览器)/s:本质上还是cs ,只是使用了浏览器:如京东,淘宝.无需安装,客户端不需要更 ...

  10. 吴裕雄 python 人工智能——智能医疗系统后台用户复诊模块简约版代码展示

    #复诊 import sys import os import time import operator import cx_Oracle import numpy as np import pand ...