温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

jQuery如何实现移动端Tab选项卡效果

发布时间:2021-06-24 15:16:06 来源:亿速云 阅读:111 作者:小新 栏目:web开发

小编给大家分享一下jQuery如何实现移动端Tab选项卡效果,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

效果图:

jQuery如何实现移动端Tab选项卡效果

代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
 <title>移动端Tab选项卡</title>
 <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
 <script>
  $(function() {
   $(".tab a").click(function() {
    $(this).addClass('curr').siblings().removeClass('curr');
    var index = $(this).index();
    number = index;
    $('.nav .content li').hide();
    $('.nav .content li:eq(' + index + ')').show();
   });
  })
 </script>
 <style>
  *{
   margin: 0;
   padding: 0;
  }
  div, input, textarea, button, a {
   -webkit-tap-highlight-color: rgba(0,0,0,0);
  }
  ul, li, ol{
   list-style: none;
  }
  a {
   color: #323232;
   outline-style: none;
   text-decoration: none;
  }
  .border-b {
   position: relative;
  }
  .border-b:after {
   top: auto;
   bottom: 0;
  }
  .border-t:before, .border-b:after {
   content: '';
   position: absolute;
   left: 0;
   background: #ddd;
   right: 0;
   height: 1px;
   -webkit-transform: scaleY(0.5);
   transform: scaleY(0.5);
   -webkit-transform-origin: 0 0;
   transform-origin: 0 0;
  }
  .nav {
   background-color: #fff;
   text-align: center;
  }
  .nav .tab {
   width: 100%;
   position: relative;
   overflow: hidden;
  }
  .tab a {
   float: left;
   width: 49%;
   height: 2.56rem;
   line-height:2.56rem;
   display: inline-block;
   border-right: 1px solid #e1e1e1;
  }
  .tab a:last-child {
   border-right: 0;
  }
  .tab .curr {
   border-bottom: 2px solid #fc7831;
   color: #fc7831;
  }
  .content ul li {
   display: none;
   padding: 3%;
   width: 94%;
  }
 </style>
</head>
<body>
<div class="nav">
 <div class="tab border-b">
  <a href="javascript:;" rel="external nofollow" rel="external nofollow" class="curr">商品介绍</a>
  <a href="javascript:;" rel="external nofollow" rel="external nofollow" >评价(99)</a>
 </div>
 <div class="content">
  <ul>
   <li >商品介绍</li>
   <li>评价</li>
  </ul>
 </div>
</div>
</body>
</html>

以上是“jQuery如何实现移动端Tab选项卡效果”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI