uniapp中scroll橫向滾動不容易正常顯示


通常商城中會有滑動的菜單,一般都是橫向的。

使用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;行內塊布局。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM