如何让元素随着文字多少自适应宽度?

<view class="test">
    测试
</view>

.test{
    display:flex;
    align-items: center;
    justify-content: center;
}

image

阅读 2.3k
2 个回答
.parent {
    display: flex;
    flex-wrap: wrap;
}
.test{
    display:inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

你现在的写法就是自适应的,用padding撑开间距就行

推荐问题