• css flex 布局换行


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

    1. .app-center {
    2. display: flex;
    3. flex-wrap: wrap;
    4. justify-content:flex-start;
    5. }

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

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

    整体代码

    1. <van-nav-bar title="应用中心" fixed="false" placeholder="false" custom-class="nav" title-class="nav-title">
    2. <!-- <view slot="left" class="leftIcon">
    3. <van-icon name="arrow-left" color="white" size="15px" />
    4. </view> -->
    5. </van-nav-bar>
    6. <scroll-view class="scrollarea" show-scrollbar="{{false}}" enhanced="{{true}}" enable-passive="{{true}}" scroll-y="{{true}}">
    7. <view class="container">
    8. <view class="app-module">
    9. <text class="module-title">应付</text>
    10. <view class="app-center">
    11. <view class="app-item">
    12. <!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> -->
    13. <van-icon name="setting-o" size="30px" />
    14. <text class="app-title">发起</text>
    15. </view>
    16. <view class="app-item">
    17. <!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> -->
    18. <van-icon name="setting-o" size="30px" />
    19. <text class="app-title">发起</text>
    20. </view>
    21. <view class="app-item">
    22. <!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> -->
    23. <van-icon name="setting-o" size="30px" />
    24. <text class="app-title">发起</text>
    25. </view>
    26. <view class="app-item">
    27. <!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> -->
    28. <van-icon name="setting-o" size="30px" />
    29. <text class="app-title">发起</text>
    30. </view>
    31. <view class="app-item">
    32. <!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> -->
    33. <van-icon name="setting-o" size="30px" />
    34. <text class="app-title">发起</text>
    35. </view>
    36. <view class="app-item">
    37. <!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> -->
    38. <van-icon name="setting-o" size="30px" />
    39. <text class="app-title">发起</text>
    40. </view>
    41. <view class="app-item">
    42. <!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> -->
    43. <van-icon name="setting-o" size="30px" />
    44. <text class="app-title">发起</text>
    45. </view>
    46. <view class="app-item">
    47. <!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> -->
    48. <van-icon name="setting-o" size="30px" />
    49. <text class="app-title">发起</text>
    50. </view>
    51. <view class="app-item">
    52. <!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> -->
    53. <van-icon name="setting-o" size="30px" />
    54. <text class="app-title">发起</text>
    55. </view>
    56. <view class="app-item">
    57. <!-- <image class="app-icon" src="{{subItem.iconUrl}}"></image> -->
    58. <van-icon name="setting-o" size="30px" />
    59. <text class="app-title">发起</text>
    60. </view>
    61. </view>
    62. </view>
    63. </view>
    64. </scroll-view>
    1. .app-module{
    2. background-color: #FFFFFF;
    3. height: auto;
    4. border-radius: 5px;
    5. padding: 10px 10px 0px 10px;
    6. }
    7. .app-center {
    8. display: flex;
    9. flex-wrap: wrap;
    10. justify-content:flex-start;
    11. }
    12. .app-module .module-title {
    13. font-weight: bold;
    14. }
    15. .app-item {
    16. flex: 1 0 calc(20% - 40px); /* 控制一行显示5个,设置间距为20px */
    17. display: flex;
    18. flex-direction: column;
    19. align-items: center;
    20. margin: 20rpx;
    21. padding: 5px;
    22. }
    23. .app-icon {
    24. width: 80rpx;
    25. height: 80rpx;
    26. }
    27. .app-title {
    28. margin-top: 10rpx;
    29. font-size: 14px;
    30. }

  • 相关阅读:
    Hystrix的原理及应用:构建微服务容错体系的利器(一)
    jenkins使用 mvnd 加速maven 项目打包
    node.js - 路由、中间件、mysql
    图扑数字孪生洗煤厂,低代码构建云端工厂
    双十二投影仪推荐 三分钟告诉你怎么挑选到称心如意的投影仪
    Python Web开发一:Web开发简介
    华为李鹏:到 2025 年智能算力需求将达到目前水平的 100 倍
    NoSQL
    降噪耳机哪款比较舒适?比较舒适的降噪耳机盘点
    51单片机直流电机控制
  • 原文地址:https://blog.csdn.net/qq873113580/article/details/136548751