查看: 2074|回复: 0
打印 上一主题 下一主题

选项卡有点问题,求高手处理

[复制链接]

该用户从未签到

1

主题

1

帖子

5

积分

新手上路

Rank: 1

积分
5
跳转到指定楼层
楼主
发表于 2020-12-1 12:02:13 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
Swiper
应用插件:
分享方式:
创作方式:
图片展示: -
<style>
.xuan{float: left;width: 100%;}
.xuan li{float: left;width: 33%;height: 50px;line-height: 50px;text-align: center;}
.xuan .active{color: red;}
.swiper5{float: left;width:100%;}
.swiper5 .swiper-container{ /*height: calc(100vh - 50px);*/}
.swiper5 .swiper-slide{/*overflow-y: scroll;*/}
</style>

<div class="xuan">       
  <ul>
    <li class="active">首页</li>
    <li>发现</li>
    <li>用户</li>
  </ul>
</div>
  <div class="swiper-container swiper5">
    <div class="swiper-wrapper">
        <div class="swiper-slide" style="background: red">
            <p style="height:50px">1</p>
            <p style="height:50px">1</p>
            <p style="height:50px">1</p>
            <p style="height:50px">1</p>
            <p style="height:50px">1</p>
            <p style="height:50px">1</p>
            <p style="height:50px">1</p>
            <p style="height:50px">1</p>
            <p style="height:50px">1</p>
            <p style="height:50px">1</p>
            <p style="height:50px">1</p>
            <p style="height:50px">1</p>
        </div>
        <div class="swiper-slide" style="background: yellow">
           <p style="height:50px">2</p>
           <p style="height:50px">2</p>
           <p style="height:50px">2</p>
           <p style="height:50px">2</p>
           <p style="height:50px">2</p>
           <p style="height:50px">2</p>
           <p style="height:50px">2</p>
           <p style="height:50px">2</p>
        </div>
        <div class="swiper-slide" style="background: pink">
          <p style="height:50px">3</p>
          <p style="height:50px">3</p>
          <p style="height:50px">3</p>
        </div>
    </div>
  </div>

        </div>
</div>

/*选项卡*/
      $('.xuan li').each(function(e) {
        var index = $(this).index();
        $(this).hover(function() {
          $(this).addClass('active').siblings().removeClass('active')
          swiper5.slideTo(index);
        })
      })
      var swiper5 = new Swiper ('.swiper5', {
        loop: false, // 循环模式选项
        on: {
          slideChange: function () {
             $('.xuan li').eq(this.activeIndex).addClass('active').siblings().removeClass('active')
          },
        }
      })


悬停可以,拉动内容不会回调,不会触发

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Swiper中文网 ( 粤ICP备15001020号

GMT+8, 2024-5-4 22:12 , Processed in 0.073597 second(s), 32 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表