// 小程序使用横向滑动时
<scroll-view scroll-x class="consult-scroll-header">
<view wx:for="{{buyCarList.articleList}}" wx:key="{{index}}" style="background-image: url({{item.imgUrl}});">
<span class="tag">{{item.tag}}</span>
<span class="title">{{item.title}}</span>
</view>
</scroll-view>
css样式
.consult-scroll-header{
display: flex;
white-space: nowrap;
}
.title{
display:block;
white-space: normal;
display: -webkit-box;
-webkit-line-clamp:2;
overflow: hidden;
text-overflow: ellipsis;
-webkit-box-orient: vertical;
}
子元素一定要加 white-space: normal 其他都不好使加了也白加
小程序横向滑动文字换行
最新推荐文章于 2024-07-31 11:41:46 发布