1、竖向滚动
首先从简单的来,竖向滚动很简单,只用记住两点即可:
- 首先得设置
scroll-y属性; - 其次,一定要给
scroll-view设置一个height高度;<scroll-view scroll-y style="height: 200px;"> <view class="green" style="width: 100%; height: 200px; background: green;"></view> <view class="red" style="width: 100%; height: 200px; background: red;"></view> <view class="yellow" style="width: 100%; height: 200px; background: yellow;"></view> <view class="blue" style="width: 100%; height: 200px; background: blue;"></view> </scroll-view>
具体参数看官网 https://developers.weixin.qq.com/miniprogram/dev/component/scroll-view.html2、横向滚动
横向滚动就有点坑了...
-
首先还是要设置滚动方向为
scroll-x; -
然后要给
<scroll-view></scroll-view>设置white-space为nowrap不换行; -
最后需要将容器中包裹的标签的
display属性设置为inline-block。 -
<scroll-view scroll-x style="width: 100%; white-space: nowrap;"> <view class="green" style="display: inline-block; width: 200px; height: 200px; background: green;"></view> <view class="red" style="display: inline-block; width: 200px; height: 200px; background: red;"></view> <view class="yellow" style="display: inline-block; width: 200px; height: 200px; background: yellow;"></view> <view class="blue" style="display: inline-block; width: 200px; height: 200px; background: blue;"></view> </scroll-view>
-
人生很漫长,或许我只是你人生中微不足道的一小段,只是你人生中的惊鸿一瞥。
浙公网安备 33010602011771号