<template> <div> <el-row :gutter="12"> <el-col class="card1" :span="8"> <el-card shadow="hover"> 鼠标悬浮时显示 </el-card> </el-col> <el-col class="card2" :span="8"> <el-card shadow="hover"> 鼠标悬浮时显示 </el-card> </el-col> <el-col class="card3" :span="8"> <el-card shadow="hover"> 鼠标悬浮时显示 </el-card> </el-col> </el-row> </div> </template> <script> import Battery from "./battery"; export default { name: "car", components: { Battery, }, data() { return { quantity: 50, }; }, }; </script> <style> .el-row { display: flex; justify-content: center; align-items: center; height: 100vh; } .el-col { border-radius: 4px; flex-grow: 1; background-color: #f0f0f0; border-radius: 10px; padding: 20px; margin: 10px; box-sizing: border-box; transition: transform 0.3s ease; } .card3 { flex-basis: 50%; } .bg-purple-dark { background: #99a9bf; } .bg-purple { background: #d3dce6; } .bg-purple-light { background: #e5e9f2; } .grid-content { border-radius: 4px; min-height: 36px; } </style>修改一下这段代码,使得card1和card2在左侧上下排列,card3在card1和2右侧单独排列,三个卡片之间都有间隙,去掉el-col的颜色和空隙,使el-card的边就是整体的边,三个卡片要将屏幕部分覆盖全,不能小
时间: 2024-04-21 14:23:08 浏览: 167
Element-UI 使用el-row 分栏布局的教程
您可以按照以下方式修改代码,实现您的需求:
```html
<template>
<div>
<el-row :gutter="12">
<el-col :span="8">
<el-card class="card" shadow="hover">鼠标悬浮时显示</el-card>
</el-col>
<el-col :span="8">
<el-card class="card" shadow="hover">鼠标悬浮时显示</el-card>
</el-col>
<el-col :span="8">
<el-card class="card" shadow="hover">鼠标悬浮时显示</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
import Battery from "./battery";
export default {
name: "car",
components: {
Battery,
},
data() {
return {
quantity: 50,
};
},
};
</script>
<style scoped>
.el-row {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.el-col {
flex-grow: 1;
padding: 20px;
box-sizing: border-box;
}
.card {
background-color: #f0f0f0;
border-radius: 10px;
margin-bottom: 20px;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
}
</style>
```
在修改后的代码中,我们将 `class` 属性添加到每个 `el-card` 元素上,并添加了一个名为 `.card` 的样式规则,该规则设置了卡片的背景色、边框半径和底部间距。同时,我们还在每个 `el-col` 元素上去除了原有的 `class` 属性和颜色样式,以及空隙样式。这样,三个卡片之间就会有间隙,并且 `el-card` 的边缘将成为整体的边缘。
此外,我们还将 `scoped` 属性添加到 `<style>` 标签上,以确保样式仅应用于当前组件。
请注意,为了达到卡片覆盖全屏的效果,您可能需要在父元素中设置适当的高度,或者在根元素中设置 `height: 100%`。
阅读全文