uni-app中实现图片左滑的效果
template:
1 <view class="my-reg"> 2 <view class="my-regs"> 3 <image class="reg-img" src="/static/图1.png" alt="" /> 4 <image class="reg-img" @tap="openDetail" src="/static/图2.png" alt="" /> 5 <image class="reg-img" src="/static/图3.png" alt="" /> 6 <image class="reg-img" src="/static/图4.png" alt="" /> 7 </view> 8 </view>
js:
css:
1 .reg-img { 2 width: 222rpx; 3 height: 116rpx; 4 margin-right:18rpx; 5 } 6 .my-reg { 7 padding:20rpx 30rpx; 8 border-bottom: 20rpx solid #F5F6F9; 9 display: flex; 10 overflow-y: hidden; 11 overflow-x: scroll 12 } 13 .my-regs{ 14 display: flex; 15 margin-right: 8px; 16 }
实现效果:图片可以左右滑动显示