记录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>
相关推荐
2501_916007472 小时前
手机使用过的痕迹能查到吗?完整查询指南与步骤
android·ios·智能手机·小程序·uni-app·iphone·webview
2501_918126912 小时前
用html5写一个打巴掌大赛
css·css3·html5
常常不爱学习2 小时前
Vue3 + TypeScript学习
开发语言·css·学习·typescript·html
街尾杂货店&4 小时前
CSS - transition 过渡属性及使用方法(示例代码)
前端·css
街尾杂货店&4 小时前
css - word-spacing 属性(指定段字之间的间距大小)属性定义及使用说明
前端·css
Amewin8 小时前
在vue3+uniapp+vite中挂载全局属性方法
javascript·vue.js·uni-app
座山雕~15 小时前
html 和css基础常用的标签和样式
前端·css·html
elvinnn16 小时前
提升页面质感:CSS 重复格子背景的实用技巧
前端·css
rising start16 小时前
五、CSS盒子模型(下)
前端·javascript·css
2501_9151063217 小时前
App HTTPS 抓包 工程化排查与工具组合实战
网络协议·ios·小程序·https·uni-app·php·iphone