容器为块元素
css样式添加: text-overflow:ellipsis; word-wrap:break-word; 实现效果:代码:
<view class="message-box"> <image class="avatar" /> <view class='text-box'> <text class="text">你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好</text> </view> </view>
.message-box { display: flex; padding: 30rpx 20rpx; background-color: green; } .avatar {
width: 100rpx;
height: 100rpx;
margin-right:20rpx; border-radius: 50rpx;
background-color: pink;} .text-box { position: relative; max-width: 70%; padding:8rpx; background-color: white; border: 2rpx solid rgb(62, 156, 98) ; border-radius:8rpx; text-overflow:ellipsis; word-wrap:break-word;
}
标签:文字,word,换行,text,文本框,color,background,border,你好 From: https://www.cnblogs.com/yheyi/p/18002028