<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> span的大小4.9如何设置
时间: 2023-08-13 13:11:35 浏览: 168
`span` 的大小只能设置为整数,不能设置为浮点数。如果需要设置为 `4.9`,可以考虑将 `span` 设置为 `5`,同时使用 `offset` 属性来调整位置,例如:
```html
<el-col :span="5" :offset="0.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>
```
上述代码中,使用 `offset` 属性将当前列向右偏移了半个列的宽度,相当于 `span` 大小为 `4.5`。您可以根据实际情况进行调整。
相关问题
<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-col :span="6"> <el-card style="color:#409EFF"> <div><i class="el-icon-user-solid"/>告警总数</div> <div style="padding:10px 0;text-align:center;font-weight:bold">1231</div> </el-card> </el-col> <el-col :span="6"> <el-card style="color:#F56C6C"> <div><i class="el-icon-money"/>销售总量</div> <div style="padding:10px 0;text-align:center;font-weight:bold">¥1000000</div> </el-card> </el-col>如何给这些块赋值
这些块看起来是用Element UI库的组件编写的。如果你想给这些块赋值,可以通过Vue.js的数据绑定来实现。
你可以在Vue.js的data对象中定义一个变量,例如:
```
data() {
return {
alarmCount: 1231,
salesAmount: 1000000
}
}
```
然后,在模板中使用这些变量来绑定数据,例如:
```
<el-col :span="6">
<el-card style="color:#409EFF">
<div><i class="el-icon-user-solid"/>告警总数</div>
<div style="padding:10px 0;text-align:center;font-weight:bold">{{ alarmCount }}</div>
</el-card>
</el-col>
<el-col :span="6">
<el-card style="color:#F56C6C">
<div><i class="el-icon-money"/>销售总量</div>
<div style="padding:10px 0;text-align:center;font-weight:bold">{{ salesAmount | currency }}</div>
</el-card>
</el-col>
```
在这个例子中,我们将Vue.js的数据绑定语法`{{ }}`用于告警总数和销售总量的值。我们还使用了Vue.js的过滤器来格式化销售总量的值为货币格式。
阅读全文