记录uniapp 滚动后溢出显示空白的办法

写了一个横向滚动,超出可视区域图片空白,上下滚动页面可视区域图片显示,不可见区域滚动出来变成空白

错误css如下

css 复制代码
   width: 678rpx;
  height: 264rpx;
    background: #ffffff;
    border-radius: 16rpx;
    margin: 64rpx 18rpx 10rpx 18rpx;
    overflow-y: hidden;
    overflow-x: auto;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;

在UniApp中实现横向滚动并且溢出显示空白,可以使用scroll-view组件。

html 复制代码
<template>
  <view class="container">
    <scroll-view class="scroll-view" scroll-x>
      <view class="item" v-for="(item, index) in items" :key="index">
        {{ item }}
      </view>
    </scroll-view>
  </view>
</template>

<style>
.container {
  width: 100%;
  height: 200px;
  overflow-x: scroll;
}

.scroll-view {
  white-space: nowrap;
}

.item {
  display: inline-block;
  width: 100px;
  height: 100px;
  background-color: #ccc;
  margin-right: 10px;
}
</style>

<script>
export default {
  data() {
    return {
      items: ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5']
    };
  }
};
</script>
相关推荐
00后程序员张2 小时前
从审核被拒到稳定过审,iOS 上架技术优化
android·ios·小程序·https·uni-app·iphone·webview
阿虎儿10 小时前
CSS 毛玻璃效果完全指南:从入门到避坑
css
清风细雨_林木木14 小时前
CSS 报错:css-semicolonexpected 解决方案
前端·css
熙街丶一人14 小时前
css 图片未加载时默认高度,加载后随图片高度
前端·javascript·css
洗发水很好用18 小时前
uniapp纯css实现基础多选组件
前端·css·uni-app
2501_9159184119 小时前
WebKit 抓包,WKWebView 请求的完整数据获取方法
android·前端·ios·小程序·uni-app·iphone·webkit
whuhewei19 小时前
CSS动画倍速播放
前端·css
ZTLJQ19 小时前
构建网页的三剑客:HTML, CSS, JavaScript 完全解析
javascript·css·html
苏武难飞20 小时前
分享一个THREE.JS中无限滚动的技巧
前端·javascript·css
橘子编程20 小时前
HTML5 权威指南:从入门到精通
前端·css·vue.js·html·html5