<el-row style="height: 500px;overflow-y: auto;"> <el-col :span="3" style="text-align:center;padding-top:20px;" v-for="(item,index) in processList" :key="index" @click.native="createProcess(item)"> <span> <!-- <svg-icon icon-class="menu" class-name="menu"/>--> <svg-icon :icon-class="item.imagePath" class-name="menu" /> </span> <span>{{ item.processName }}</span> </el-col> </el-row>增加什么样式让他自动换行
时间: 2024-01-03 16:38:20 浏览: 28
要使el-col自动换行,您可以使用CSS的flex-wrap属性来实现。将flex-wrap设置为wrap,即可使元素自动换行。
以下是修改后的代码示例:
```vue
<el-row style="height: 500px; overflow-y: auto; flex-wrap: wrap;">
<el-col :span="3" style="text-align: center; padding-top: 20px;" v-for="(item, index) in processList" :key="index" @click.native="createProcess(item)">
<span>
<svg-icon :icon-class="item.imagePath" class-name="menu" />
</span>
<span>{{ item.processName }}</span>
</el-col>
</el-row>
```
在这个示例中,我们在el-row元素上添加了flex-wrap: wrap样式,这将使el-col元素在需要时自动换行。
希望这个修改能够满足您的需求。如果还有其他问题,请随时提问。
相关问题
<el-col :span="5"> <el-card style="color:#409EFF"> <div style="color:#409EFF"><i class="el-icon-s-shop"/>能力发布驳回数</div> <div style="padding:10px 0;text-align:center;font-weight:bold">100</div> </el-card> </el-col> <el-col :span="5"> <el-card style="color:#409EFF"> <div style="color:#409EFF"><i class="el-icon-s-shop"/>人工告警数量</div> <div style="padding:10px 0;text-align:center;font-weight:bold">100</div> </el-card> </el-col> <el-col :span="5"> <el-card style="color:#409EFF"> <div style="color:#409EFF"><i class="el-icon-s-shop"/>自动告警数量</div> <div style="padding:10px 0;text-align:center;font-weight:bold">100</div> </el-card> </el-col> <el-col :span="5"> <el-card style="color:#409EFF"> <div style="color:#409EFF"><i class="el-icon-s-shop"/>钉钉告警数量</div> <div style="padding:10px 0;text-align:center;font-weight:bold">100</div> </el-card> </el-col> <el-col :span="5"> <el-card style="color:#409EFF"> <div style="color:#409EFF"><i class="el-icon-s-shop"/>BOMC告警数量</div> <div style="padding:10px 0;text-align:center;font-weight:bold">100</div> </el-card> </el-col> </el-row>如何让这五个卡片大小统一展示在一条线上
你可以尝试在每个 `<el-col>` 元素中添加 `align="center"` 属性,同时在最外层的 `<el-row>` 元素中添加 `justify="center"` 属性,代码如下:
```
<el-row justify="center">
<el-col :span="5" align="center">
<el-card style="color:#409EFF">
<div style="color:#409EFF"><i class="el-icon-s-shop"/>能力发布驳回数</div>
<div style="padding:10px 0;text-align:center;font-weight:bold">100</div>
</el-card>
</el-col>
<el-col :span="5" align="center">
<el-card style="color:#409EFF">
<div style="color:#409EFF"><i class="el-icon-s-shop"/>人工告警数量</div>
<div style="padding:10px 0;text-align:center;font-weight:bold">100</div>
</el-card>
</el-col>
<el-col :span="5" align="center">
<el-card style="color:#409EFF">
<div style="color:#409EFF"><i class="el-icon-s-shop"/>自动告警数量</div>
<div style="padding:10px 0;text-align:center;font-weight:bold">100</div>
</el-card>
</el-col>
<el-col :span="5" align="center">
<el-card style="color:#409EFF">
<div style="color:#409EFF"><i class="el-icon-s-shop"/>钉钉告警数量</div>
<div style="padding:10px 0;text-align:center;font-weight:bold">100</div>
</el-card>
</el-col>
<el-col :span="5" align="center">
<el-card style="color:#409EFF">
<div style="color:#409EFF"><i class="el-icon-s-shop"/>BOMC告警数量</div>
<div style="padding:10px 0;text-align:center;font-weight:bold">100</div>
</el-card>
</el-col>
</el-row>
```
这样设置后,每个卡片的宽度会被限定在 `<el-col>` 元素的宽度内,同时 `<el-row>` 元素的 `justify` 属性可以让所有的元素在水平方向上居中对齐。
<el-row style="flex-wrap: wrap;height: 500px;overflow-y: auto;"> <el-col :span="3" style="text-align:center;padding-top:20px;" v-for="(item,index) in processList" :key="index" @click.native="createProcess(item)"> <span> <!-- <svg-icon icon-class="menu" class-name="menu"/>--> <svg-icon :icon-class="item.imagePath" class-name="menu" /> </span> <span>{{ item.processName }}</span> </el-col> </el-row> 让他每行居左开始
要让el-col每行居左开始,您可以使用flex布局的`justify-content`属性来实现。将`justify-content`设置为`flex-start`,即可使每行元素左对齐。
以下是修改后的代码示例:
```vue
<el-row style="flex-wrap: wrap;height: 500px;overflow-y: auto; justify-content: flex-start;">
<el-col :span="3" style="text-align:center;padding-top:20px;" v-for="(item,index) in processList" :key="index"
@click.native="createProcess(item)">
<span>
<svg-icon :icon-class="item.imagePath" class-name="menu" />
</span>
<span>{{ item.processName }}</span>
</el-col>
</el-row>
```
在修正后的代码中,我们在`el-row`元素上添加了`justify-content: flex-start;`样式,使得每行的元素居左开始对齐。
希望这个修正能够满足您的需求。如果还有其他问题,请随时提出。