uniapp中的多个<view>或<text>如何显示在同一行

将要显示在同一行的多个view或者text标签用一个view标签包起来
代码如下

//情况1(html代码)
<view class="propertyBox">
	<text class="title1">标签编号:</text>
	<text class="content1">{
    
    {
    
    checkLabel.code}}</text>
</view>
//情况2(html代码)
<view class="propertyBox3">
	<text class="content2" v-for="(item, index) in deviceList">{
    
    {
    
    item.name}}</text>
</view>
//css代码
.propertyBox{
    
    
		flex-flow: row;
		justify-content: flex-start;
		display: flex;
	}

效果如下
在这里插入图片描述
根据文本布局要求可修改justify-content:这个属性

/* 对齐方式 */
justify-content: center;     /* 居中排列 */
justify-content: start;      /* 从行首开始排列 */
justify-content: end;        /* 从行尾开始排列 */
justify-content: flex-start; /* 从行首起始位置开始排列 */
justify-content: flex-end;   /* 从行尾位置开始排列 */
justify-content: left;       /* 一个挨一个在对齐容器得左边缘 */
justify-content: right;      /* 元素以容器右边缘为基准,一个挨着一个对齐, */

/* 基线对齐 */
justify-content: baseline;
justify-content: first baseline;
justify-content: last baseline;

/* 分配弹性元素方式 */
justify-content: space-between;  /* 均匀排列每个元素
                                   首个元素放置于起点,末尾元素放置于终点 */
justify-content: space-around;  /* 均匀排列每个元素
                                   每个元素周围分配相同的空间 */
justify-content: space-evenly;  /* 均匀排列每个元素
                                   每个元素之间的间隔相等 */
justify-content: stretch;       /* 均匀排列每个元素
                                   'auto'-sized 的元素会被拉伸以适应容器的大小 */

/* 溢出对齐方式 */
justify-content: safe center;
justify-content: unsafe center;

/* 全局值 */
justify-content: inherit;
justify-content: initial;
justify-content: unset;

猜你喜欢

转载自blog.csdn.net/weixin_46820967/article/details/126248174