uniapp设置横向滚动

关键:【.scroll 设置 white-space: nowrap】 

<template>
	<view class="prefer-content">
		<!-- 标题 -->
		<view class="prefer-title">为你优选</view>
		<scroll-view scroll-x="true" class="scroll" scroll-with-animation="true">
			<view class="prefer-dis">
				<block v-for="(item, index) in preferdata" :key="index">
					<view class="prefer-view">
						<image :src="item.image" mode="aspectFill"></image>
						<text>{{ item.title }}</text>
						<text>{{ item.lable }}</text>
					</view>
				</block>
			</view>
		</scroll-view>
	</view>
</template>

<script>
export default {
	props: {
		preferdata: Array
	},
	data() {
		return {};
	}
};
</script>

<style scoped>
.prefer-content {
	margin: 30upx 0;
}
.prefer-title {
	font-size: 35upx;
	height: 50upx;
	line-height: 50upx;
	margin-bottom: 20upx;
}
.scroll {
	white-space: nowrap;
	width: 100%;
	height: 300upx;
}
.prefer-dis {
	display: flex;
	justify-content: space-between;
}
.prefer-view {
	height: 300upx;
	width: 300upx;
	padding: 0 8upx;
}
.prefer-view image {
	width: 300upx;
	height: 200upx;
	border-radius: 8upx;
}
.prefer-view text {
	height: 45upx;
	line-height: 45upx;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 1;
	overflow: hidden;
}
.prefer-view text:nth-child(2) {
	font-size: 30upx;
}
.prefer-view text:nth-child(3) {
	font-size: 27upx;
	color: #9c9c9c;
}
.prefer-dis view:nth-child(2) {
	padding: 0 7upx !important;
}
</style>

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值