posts - 39,comments - 0,views - 33590

一、方法1:css word-break

word-break: break-all;
在需要换行的view上添加这个样式

 

 

二、方法2:css width %

如显示3个一排。
使用的是width: 31%;

wxml文件
<!--3个一排,超过换行-->
<view class="link">
<view class="link_child"> 1212 </view>
<view class="link_child"> 1212 </view>
<view class="link_child"> 1212 </view>
<view class="link_child"> 1212 </view>
</view>

wxss文件
.link {
display: flex; flex-direction: row;
flex-wrap: wrap; width: 654rpx;
margin: 0 auto; position: relative;
left: 5rpx;
}
.link_child {
width: 31%;
background: red;
border: 1rpx solid black;
}
.link_child:not(:nth-child(3n)){
margin-right: 10rpx;
}

 

三、方法3:css width rpx

如显示3个一排。
使用的 width: 200rpx;(需要是3的倍数)

wxml文件
<view class="father">
<view class="child test"> 1 </view>
<view class="child test"> 2 </view>
<view class="child test"> 3 </view>
<view class="child test"> 4 </view>
<view class="child test"> 5 </view>
<view class="child test"> 6 </view>
</view>

wxss文件
.test {
border: 2rpx solid black;
}
.father {
width: 660rpx;
display:flex;
flex-wrap:wrap;
justify-content:space-between;
}
.child{
width: 200rpx;
}

posted on   林多多  阅读(2628)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示