当前位置: 首页 > news >正文

css flex 布局换行

默认使用display: flex;是不换行的,只需要加上flex-wrap: wrap;就行了,效果图

.app-center {display: flex;flex-wrap: wrap;justify-content:flex-start;
}

通过上面我们发现虽然时间换行了,但是每行的边距不一样

加上这个就行了:flex: 1 0 calc(20% - 40px); /* 控制一行显示5个,设置间距为20px */,最后效果

整体代码

<van-nav-bar title="应用中心" fixed="false" placeholder="false" custom-class="nav" title-class="nav-title"><!-- <view slot="left" class="leftIcon"><van-icon name="arrow-left" color="white" size="15px" /></view> -->
</van-nav-bar>
<scroll-view class="scrollarea" show-scrollbar="{{false}}" enhanced="{{true}}" enable-passive="{{true}}" scroll-y="{{true}}"><view class="container"><view class="app-module"><text class="module-title">应付</text><view class="app-center"><view class="app-item"><!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> --><van-icon name="setting-o" size="30px" /><text class="app-title">发起</text></view><view class="app-item"><!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> --><van-icon name="setting-o" size="30px" /><text class="app-title">发起</text></view><view class="app-item"><!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> --><van-icon name="setting-o" size="30px" /><text class="app-title">发起</text></view><view class="app-item"><!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> --><van-icon name="setting-o" size="30px" /><text class="app-title">发起</text></view><view class="app-item"><!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> --><van-icon name="setting-o" size="30px" /><text class="app-title">发起</text></view><view class="app-item"><!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> --><van-icon name="setting-o" size="30px" /><text class="app-title">发起</text></view><view class="app-item"><!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> --><van-icon name="setting-o" size="30px" /><text class="app-title">发起</text></view><view class="app-item"><!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> --><van-icon name="setting-o" size="30px" /><text class="app-title">发起</text></view><view class="app-item"><!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> --><van-icon name="setting-o" size="30px" /><text class="app-title">发起</text></view><view class="app-item"><!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> --><van-icon name="setting-o" size="30px" /><text class="app-title">发起</text></view></view></view></view>
</scroll-view>
.app-module{background-color: #FFFFFF;height: auto;border-radius: 5px;padding: 10px 10px 0px 10px;
}.app-center {display: flex;flex-wrap: wrap;justify-content:flex-start;
}.app-module .module-title {font-weight: bold;
}.app-item {flex: 1 0 calc(20% - 40px); /* 控制一行显示5个,设置间距为20px */display: flex;flex-direction: column;align-items: center;margin: 20rpx;padding: 5px;
}.app-icon {width: 80rpx;height: 80rpx;
}.app-title {margin-top: 10rpx;font-size: 14px;
}

http://www.lryc.cn/news/313371.html

相关文章:

  • 使用腾讯云快速搭建WordPress网站流程详解
  • JavaScript发展历史与JavaScript的版本发展
  • 零基础如何系统自学Python
  • 华为OD机试 - 字符串统计(Java 2024 C卷 100分)
  • LeetCode-数组-前缀和-中等难度
  • 【程序人生】探索2024年AI辅助研发趋势
  • 集合框架(一)Collection
  • Android 性能优化--APK加固(2)加密
  • Linux环境下使用interrupt方式操作UART
  • 修改Android打包apk的名字和目录
  • 管理 PostgreSQL 中配置参数的各种方法
  • Linux命令-continue命令(结束本次循环,继续执行下一个for,while或until循环。)
  • 智能部署之巅:Amazon SageMaker 引领机器学习革新
  • 国内哪个工具可以平替chatgpt?国内有哪些比较好用的大模型gpt?
  • python如何打包py文件为exe
  • yolov9网络结构图
  • Spark 核心API
  • OpenLayers线性渐变和中心渐变(径向渐变)
  • [210. 课程表 II] 拓扑排序模板(DFS+BFS)
  • 我的第一个python web 网站
  • 产品展示型wordpress外贸网站模板
  • 四信全球化拓展再启新篇!LoRa传感器与云平台领航智能感知时代
  • 阿里云k8s环境下,因slb限额导致的发布事故
  • 【STM32+OPENMV】矩形识别
  • 在吗?腾讯云服务器优惠价格表曝光_2023年3月报价请过目!
  • Revit-二开之创建Plane-(7)
  • 【操作系统学习笔记】文件管理1.2
  • 算法归纳【数组篇】
  • 【随笔】程序员如何选择职业赛道,目前各个赛道的现状如何,那个赛道前景巨大
  • 进程之舞:操作系统中的启动、状态转换与唤醒艺术