通常商城中會有滑動的菜單,一般都是橫向的。
使用uniapp開發常用scroll-view組件。
<view class="scroll-view-box">
<scroll-view class="scrollView" scroll-x="true" scroll-with-animation>
<view class="item-box" >
<view id="demo1" class="item">
</view>
</view>
</scroll-view>
</view>
.scrollView{
height: 297rpx;
width: 750rpx;
white-space: nowrap;
text-align:center;
overflow: hidden;
.item-box{
display:inline-block;
.item{
margin-left: 20rpx;
display:flex;
flex-direction: column;
}
}
}
其中 white-space: nowrap;
要添加到 scroll-view標簽上
並且要聲明寬高
內部第一個標簽為其中的item項,寬度要大於scroll-view標簽的寬度,並且添加上 display:inline-block;
行內塊布局。