微信小程序(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:100%;height: 50px;border-bottom:1px solid #349393;position: fixed;top:0;left:0;z-index: 999;overflow: hidden;background: linear-gradient(to right,#f3f3f3,#fff,#f3f3f3); }
.self-box{position: absolute;left:0;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:100%;height: 100%;}
.self-add{position: absolute;right:0;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:100%;height: 100%;}
.scroll-view_H{white-space:nowrap;width: 100%;padding:6px 40px 0;box-sizing: border-box;}
.nav-name{display:inline-block;font-size:16px;color: #2b2e33;border-bottom: 2px solid transparent;padding:10px;}
.nav-hover{color: #349393;/* border-bottom: 2px solid #f06000; */}
data: {
    section: [
      { name: '精選', id: '1001' }, { name: '黃金單身漢', id: '1032' },
      { name: '綜藝', id: '1003' }, { name: '電視劇', id: '1004' },
      { name: '電影', id: '1005' }, { name: '少兒', id: '1021' }
    ]
  },

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM