微信小程序:flex布局实现换行

1、关键代码.wxml:

复制代码
<view class="pay margin-top-40">
    <view class="info">
      <view class="pay-info-title margin-left-22 flex-start"> 请选择充值金额</view>

      <view class="flex-wrap margin-top-20">
        <view class="pay-item-select flex-center margin-left-22">
          <view class="pay-item-detail flex-center">
            <view>
              <view class="pay-item-detail-top flex-start">
                <view class="pay-jbi flex-center">
                  <image src="https://images.xxx.com/my_pay_jinbi.png" />
                </view>
                <view class="pay-item-detail-top-money flex-center">80</view>
              </view>
              <view>¥ 80.00</view>
            </view>
          </view>
        </view>

        <view class="pay-item flex-center margin-left-22">
          <view class="pay-item-detail flex-center">
            <view>
              <view class="pay-item-detail-top flex-start">
                <view class="pay-jbi flex-center">
                  <image src="https:/images.xxx.com/my_pay_jinbi.png" />
                </view>
                <view class="pay-item-detail-top-money flex-center">80</view>
              </view>
              <view>¥ 80.00</view>
            </view>
          </view>
        </view>

        <view class="pay-item flex-center margin-left-22">
          <view class="pay-item-detail flex-center">
            <view>
              <view class="pay-item-detail-top flex-start">
                <view class="pay-jbi flex-center">
                  <image src="https://images.xxx.com/my_pay_jinbi.png" />
                </view>
                <view class="pay-item-detail-top-money flex-center">80</view>
              </view>
              <view>¥ 80.00</view>
            </view>
          </view>
        </view>

        <view class="pay-item flex-center margin-left-22">
          <view class="pay-item-detail flex-center">
            <view>
              <view class="pay-item-detail-top flex-start">
                <view class="pay-jbi flex-center">
                  <image src="https://images.xxxx.com/my_pay_jinbi.png" />
                </view>
                <view class="pay-item-detail-top-money flex-center">80</view>
              </view>
              <view>¥ 80.00</view>
            </view>
          </view>
        </view>

        <view class="pay-item flex-center margin-left-22">
          <view class="pay-item-detail flex-center">
            <view>
              <view class="pay-item-detail-top flex-start">
                <view class="pay-jbi flex-center">
                  <image src="https://images.xxx.com/my_pay_jinbi.png" />
                </view>
                <view class="pay-item-detail-top-money flex-center">80</view>
              </view>
              <view>¥ 80.00</view>
            </view>
          </view>
        </view>

        <view class="pay-item flex-center margin-left-22">
          <view class="pay-item-detail flex-center">
            <view>
              <van-cell-group>
                <van-field type="number" maxlength='6' clearable custom-style="background-color: #F9F9F9;" placeholder="其它金额" input-align="center" bind:change="onChange" />
              </van-cell-group>
            </view>
          </view>
        </view>

      </view>
    </view>
  </view>

2、关键代码.wxss:

复制代码
/* 实现换行 */
.flex-wrap {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
}

.pay .pay-item {
  width: 220rpx;
  height: 140rpx;
  background: #F9F9F9;
  border-radius: 20rpx;
  border: 2rpx solid #E9E9E9;
  margin-top: 20rpx;
}

.pay .pay-item-select{
  width: 220rpx;
  height: 140rpx;
  border:3rpx solid #FF5000;
  border-radius: 20rpx;
  background: #FFF6EE;
  margin-top: 20rpx;
}

.pay .pay-item-detail .pay-input{
  background-color: #F9F9F9;
}

效果:

相关推荐
hi星尘4 小时前
深度解析:基于Python的微信小程序自动化操作实现
python·微信小程序·自动化
人工智能的苟富贵8 小时前
微信小程序直传阿里云 OSS 实践指南(V4 签名 · 秒传支持 · 高性能封装)
阿里云·微信小程序·小程序
时之彼岸Φ8 小时前
Fiddler+Yakit实现手机流量抓包和小程序抓包
智能手机·小程序·fiddler
换日线°9 小时前
微信小程序根据图片生成背景颜色有效果图
微信小程序
suncentwl10 小时前
为什么选择有版权的答题pk小程序
小程序·答题小程序·答题pk
小旋风0123411 小时前
uniapp自定义头部(兼容微信小程序(胶囊和状态栏),兼容h5)
微信小程序·uni-app·notepad++
GalenZhang88813 小时前
Java生成微信小程序码及小程序短链接
java·微信小程序·小程序
浮桥14 小时前
uniapp -- 实现微信小程序、app、H5端视频上传
微信小程序·uni-app·音视频
说私域16 小时前
从大众传媒到数字生态:开源AI智能名片链动2+1模式S2B2C商城小程序驱动的营销革命
人工智能·小程序·开源·零售
换日线°16 小时前
微信小程序连续多个特殊字符自动换行解决方法
微信小程序