html横向选项卡 js,JS实现滑动菜单效果代码(包括Tab,选项卡,横向等效果)

本文实例讲述了JS实现滑动菜单效果代码。分享给大家供大家参考。具体如下:

这里实现一个特效将网页中的选项卡滑动门都集中到一个网页中来,有些同志曾经为同一个页面布置两个滑动门而烦恼,参考一下本例子,相信你会找到答案,而且有各种排列方式的选项卡,总有一款会满足你。

运行效果截图如下:

9fc4e203d05d7ea2e0cdcbaba246f171.png

在线演示地址如下:

具体代码如下:

/p>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

选项卡
首页

嘿嘿,无视div原始class值。

测试

继续无视h3原始class值。

无聊

h3没有值也可以~

傻蛋

div没有值一样可以~

首页
  1. 嘿嘿,无视容器原始class值。
测试
  1. 继续无视h3原始class值。
无聊
  1. h3没有值也可以~
傻蛋
  1. div没有值一样可以~
首页

嘿嘿,无视h3原始class值。

测试

继续无视div原始class值。

无聊

h3没有值也可以~

傻蛋

class值相似一样也可以~

指定class后,即时再多一个div也行。

希望本文所述对大家的JavaScript程序设计有所帮助。

以下是uniapp实现横向选项卡代码示例: ```vue <template> <view class="tab-control"> <view class="tab-control-top"> <view class="tab-control-item" :class="{ 'active': currentIndex === index }" v-for="(item, index) in titles" :key="index" @click="handleItemClick(index)" > {{ item }} </view> </view> <view class="tab-control-content"> <swiper :current="currentIndex" @change="handleSwiperChange"> <swiper-item v-for="(item, index) in titles" :key="index"> <view class="tab-control-panel">{{ item }} 内容区域</view> </swiper-item> </swiper> </view> </view> </template> <script> export default { data() { return { currentIndex: 0, titles: ['选项卡1', '选项卡2', '选项卡3'] }; }, methods: { handleItemClick(index) { this.currentIndex = index; }, handleSwiperChange(event) { this.currentIndex = event.detail.current; } } }; </script> <style> .tab-control { height: 100%; display: flex; flex-direction: column; } .tab-control-top { display: flex; height: 80rpx; background-color: #fff; box-shadow: 0 2rpx 5rpx rgba(0, 0, 0, 0.1); } .tab-control-item { flex: 1; display: flex; justify-content: center; align-items: center; font-size: 32rpx; color: #666; } .tab-control-item.active { color: #f00; } .tab-control-content { flex: 1; } .tab-control-panel { height: 100%; display: flex; justify-content: center; align-items: center; font-size: 32rpx; color: #666; } </style> ``` 以上代码实现了一个简单的横向选项卡包括选项卡标题和内容区域。选项卡标题使用flex布局实现,点击标题可以切换内容区域。内容区域使用swiper组件实现,可以左右滑动切换选项卡
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值