通常商城中会有滑动的菜单,一般都是横向的。
使用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;
行内块布局。