Vue横向滚动-组件(web,uniapp)

实现代码 
  <div style="display: flex">
    <div class="flexStyle">
      <div
        v-for="index in list"
        :key="index.id"
        style="margin-right: 20px;display: flex;">

        <img class="contentStyle" :src="index.picurl "/>

        <div style="display: flex; flex-direction: column; ">
          <span>{{index.name}}</span>
          <span>{{index.eglish_name}}</span>
        </div>

      </div>
    </div>
  </div>
<style>
.flexStyle {
  width: 95%;
  height: 80px;
  display: flex;
  /* justify-content: space-between; */
  /* 设置超出滚动 */
  overflow-x: auto;
}

.contentStyle {
  width: 50px;
  height: 50px;
  display: inline-block;
  background: #a3a2a2;
  /* 超出滚动的关键,没有它元素会自动缩小,不会滚动 */
  flex-shrink: 0;
  margin-right: 10px;
}

::-webkit-scrollbar {
  /* 隐藏滚动条 */
  display: none;
}
</style>

 

uniapp

<scroll-view class="scroll" scroll-x scroll-y style="margin-top: 50px;">
	<view class="group">
		<view class="item">A</view>
		<view class="item">B</view>
		<view class="item">C</view>
		<view class="item">D</view>
		<view class="item">E</view>
		<view class="item">F</view>
		<view class="item">G</view>
	</view>
</scroll-view>
  .scroll {
    border: 1px solid red;
    box-sizing: border-box;
    height: 120upx;
    .group {
      white-space: nowrap;
      .item {
        width: 120upx;
        height: 120upx;
        background-color: bisque;
        display: inline-block;
        margin-right: 10upx;
      }
    }
  }

实现效果

 效果

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值