微信小程序-横向滑动scroll-view隐藏滚动条

文章转载自:https://blog.csdn.net/qq_24734285/article/details/53912799

wxml

<scroll-view class="recommend_scroll_x_box" scroll-x="true">
    <view class="recommend_hot_box" wx:for="{{hotList}}">
        <image src="{{item.pic}}" class="recommend_hot_image"></image>
    </view>
</scroll-view>

wxss

.recommend_scroll_x_box {
    height: 245rpx;
    white-space: nowrap;
    display: flex;
}

::-webkit-scrollbar {
    width: 0;
    height: 0;
    color: transparent;
}

.recommend_hot_box {
    width: 230rpx;
    height: 245rpx;
    margin-right: 24rpx;
    display: inline-block;
}

.recommend_hot_image {
    width: 230rpx;
    height: 143rpx;
}

js

Page({
    data: {
        hotList: [
        {
            pic: '/images/example2.png',
            title: '玻璃棧道',
            desc: '22W人去過'
        }, {
            pic: '/images/example2.png',
            title: '玻璃棧道',
            desc: '22W人去過'
        }, {
            pic: '/images/example2.png',
            title: '玻璃棧道',
            desc: '22W人去過'
        }, {
            pic: '/images/example2.png',
            title: '玻璃棧道',
            desc: '22W人去過'
        }, {
            pic: '/images/example2.png',
            title: '玻璃棧道',
            desc: '22W人去過'
        }]
    }
})

最后,根据网友“夸克逃逸”的提醒,强调一下最主要的代码是wxss里的这行:

::-webkit-scrollbar {
    width: 0;
    height: 0;
    color: transparent;
}

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值