elementui的tabel操作列按钮换行后如何对齐
时间: 2024-03-06 07:47:33 浏览: 56
如果 Element UI 的 Table 操作列按钮换行后需要对齐,可以使用 CSS 样式来实现。具体步骤如下:
1. 在 Table 中的操作列按钮外围包裹一个 div 容器,并设置该容器的样式 `display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: center;`,表示该容器内的子元素按照 flex 布局进行排列,允许换行,左对齐,并垂直居中对齐。
```html
<el-table>
<el-table-column label="姓名" prop="name"></el-table-column>
<el-table-column label="年龄" prop="age"></el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<div class="operate">
<el-button type="primary" size="small">编辑</el-button>
<el-button type="danger" size="small">删除</el-button>
</div>
</template>
</el-table-column>
</el-table>
```
```css
.operate {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
align-items: center;
}
```
2. 设置操作列按钮的样式 `margin-right: 10px; margin-bottom: 10px;`,表示操作列按钮之间的间距为 10px,换行后下一行按钮与上一行按钮的间距也为 10px。
```css
.operate button {
margin-right: 10px;
margin-bottom: 10px;
}
```
这样就可以实现 Element UI 的 Table 操作列按钮换行后对齐的效果了。
相关推荐
![vue](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)