mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-12-05 05:38:24 +08:00
3.1 KiB
3.1 KiB
Card
Integrate information in a card container.
Basic usage
Card includes title, content and operations.
:::demo Card is made up of header
and body
. header
is optional, and its content distribution depends on a named slot.
<el-card class="box-card">
<div slot="header" class="clearfix">
<span style="line-height: 36px;">Card name</span>
<el-button style="float: right;" type="primary">Operation button</el-button>
</div>
<div v-for="o in 4" class="text item">
{{'List item ' + o }}
</div>
</el-card>
<style>
.text {
font-size: 14px;
}
.item {
padding: 18px 0;
}
.clearfix:before,
.clearfix:after {
display: table;
content: "";
}
.clearfix:after {
clear: both
}
.box-card {
width: 480px;
}
</style>
:::
Simple card
The header part can be omitted.
:::demo
<el-card class="box-card">
<div v-for="o in 4" class="text item">
{{'List item ' + o }}
</div>
</el-card>
<style>
.text {
font-size: 14px;
}
.item {
padding: 18px 0;
}
.box-card {
width: 480px;
}
</style>
:::
With images
Display richer content by adding some configs.
:::demo The body-style
attribute defines CSS style of custom body
. This example also uses el-col
for layout.
<el-row>
<el-col :span="8" v-for="(o, index) in 2" :offset="index > 0 ? 2 : 0">
<el-card :body-style="{ padding: '0px' }">
<img src="~examples/assets/images/hamburger.png" class="image">
<div style="padding: 14px;">
<span>Yummy hamburger</span>
<div class="bottom clearfix">
<time class="time">{{ currentDate }}</time>
<el-button type="text" class="button">Operating button</el-button>
</div>
</div>
</el-card>
</el-col>
</el-row>
<style>
.time {
font-size: 13px;
color: #999;
}
.bottom {
margin-top: 13px;
line-height: 12px;
}
.button {
padding: 0;
float: right;
}
.image {
width: 100%;
display: block;
}
.clearfix:before,
.clearfix:after {
display: table;
content: "";
}
.clearfix:after {
clear: both
}
</style>
<script>
export default {
data() {
return {
currentDate: new Date()
};
}
}
</script>
:::
Attributes
Attribute | Description | Type | Accepted Values | Default |
---|---|---|---|---|
header | Title of the card. Also accepts a DOM passed by slot#header |
string | — | — |
body-style | CSS style of body | object | — | { padding: '20px' } |