Skip to content

使用flex实现左右布局

需求

Image text

实现上面的效果,竖线和历史搜索在最左边,删除图标在最右边

实现

第一种:

竖线和历史搜索放在一个view里,外层用display: flexjustify-content: space-between

第二种:

可以在中间加一个view,设置样式flex: 1,将俩边撑开

<view class="history-title">
    <view class="slide"></view>
    <text>历史搜索</text>
    <view style="flex:1"></view>
    <view bind:tap="onDeleteHistory" class="icon">
        <l-icon name="delete" color="#999999" size="32"></l-icon>
    </view>
</view>

如有转载或 CV 的请标注本站原文地址