微信小程序(8)--头部导航滑动

时间:2023-03-08 19:55:05
微信小程序(8)--头部导航滑动

项目需求:实现头部导航,可左右滑动。

微信小程序(8)--头部导航滑动

<view class="top-news">
<view class="self-box">
<view class="img-self">
<image src="../../images/self.jpg"></image>
</view>
</view>
<view class="self-add">
<view class="img-add">
<image src="../../images/add.jpg"></image>
</view>
</view>
<view class="nav-scroll">
<scroll-view class="scroll-view_H" scroll-x="true" style="width: 100%">
<text wx:for="{{section}}" wx:key="id" id="{{item.id}}" catchtap="handleTap" class="nav-name {{item.id == currentId ? 'nav-hover' : ''}}">{{item.name}}</text>
</scroll-view>
</view>
</view>
/* 头部滑动导航 */
.top-news{width:%;height: 50px;border-bottom:1px solid #;position: fixed;top:;left:;z-index: ;overflow: hidden;background: linear-gradient(to right,#f3f3f3,#fff,#f3f3f3); }
.self-box{position: absolute;left:;height:50px;width:40px;display: inline-block;background: #fff;}
.img-self{width:30px;height: 30px;padding-top:10px;padding-left: 5px;}
.img-self image{width:%;height: %;}
.self-add{position: absolute;right:;height:50px;width:40px;display: inline-block;background: #fff;}
.img-add{width:30px;height: 30px;padding-top:10px;padding-left: 5px;}
.img-add image{width:%;height: %;}
.scroll-view_H{white-space:nowrap;width: %;padding:6px 40px ;box-sizing: border-box;}
.nav-name{display:inline-block;font-size:16px;color: #2b2e33;border-bottom: 2px solid transparent;padding:10px;}
.nav-hover{color: #;/* border-bottom: 2px solid #f06000; */}
data: {
section: [
{ name: '精选', id: '' }, { name: '黄金单身汉', id: '' },
{ name: '综艺', id: '' }, { name: '电视剧', id: '' },
{ name: '电影', id: '' }, { name: '少儿', id: '' }
]
},