Card Title
Some quick example text to build on the card title and make up the bulk of the card's content.
Go somewhere卡片是一种灵活且可扩展的内容容器。 它包括页眉和页脚选项,各种内容,上下文背景颜色以及强大的显示选项。
卡片的标记和样式尽可能少,但是仍然可以提供大量的控制和自定义功能。 内置flexbox,它们易于对准并与其他组件混合良好组件。
<b-card>
没有固定的开始宽度,因此它们自然会填充其父元素的整个宽度。
您可以通过样式或标准的Bootstrap v4尺寸设置类轻松地对其进行自定义。
通过 tag
属性指定,将默认的 div
根标签更改为任何其他HTML元素。
Some quick example text to build on the card title and make up the bulk of the card's content.
Go somewhere卡片支持各种各样的内容,包括图像、文本、列表组、链接等等。下面是 <b-card>
支持的示例
<b-card>
的构建块是
<b-card-body>
部分,它提供了卡片内的填充部分。
默认情况下, <b-card>
内容自动放置在 <b-card-body>
节中:
通过在 <b-card>
上设置 no-body
属性禁用自动 <b-card-body>
部分(和相关的填充)。
请注意,no-body
启用后,title
和 sub-title
道具的内容将不会渲染。
使用 <b-card-body>
子组件将您自己的卡片主体放置在 no-body
的 <b-card>
组件中。
卡片标题 是通过 title
属性添加的,子标题 是通过
sub-title
属性添加的。标题使用子组件渲染,<b-card-title>
而子标题使用子组件渲染 <b-card-sub-title>
。
通过子组件 <b-card-text>
,可以将段落文本添加到卡片中。最后一个
<b-card-text>
将会被自动删除(通过CSS)。<b-card-text>
中的文本也可以使用标准的HTML标记样式化。
通过将 .card-link
类添加到 <a>
标签(或 <b-link>
组件)中,可以添加链接并将它们放在一起。
Some quick example text to build on the card title and make up the bulk of the card's content.
A second paragraph of text in the card.
Card link Another link该 <b-card>
属性 img-src
将图像放置在卡的顶部,并使用 img-alt
属性指定要在图像 alt
属性中放置的字符串。由 img-src
道具指定的图像将响应并在更改卡的宽度时调整其宽度。
或者,您可以 <b-card>
使用子组件手动将图像放置在内部 <b-card-img>
。有关用法,请参见下面的厨房水槽示例。
Some quick example text to build on the card and make up the bulk of the card's content.
Some quick example text to build on the card and make up the bulk of the card's content.
Some quick example text to build on the card and make up the bulk of the card's content.
Some quick example text to build on the card and make up the bulk of the card's content.
注意: 对于左边和右边的图像,您可能需要对 .card-img-left
和 .card-img-right
类应用额外的样式,因为如果您的内容比图像高,图像将在高度上“拉伸”。注意:当图像左对齐或右对齐时,不支持页眉和页脚。您可能会发现,在创建响应式
水平卡片布局 时,水平卡片布局示例更加灵活。
通过设置布尔属性值(叠加) overlay
,将图像置于卡片的背景中:
使用 <b-card-img-lazy>
子组件在图像滚动到视图中时延迟加载图像。
<b-card-img-lazy>
支持与 <b-card-img>
相同的属性以及
<b-img-lazy>
组件的许多属性。
通过页眉/页脚属性或命名的插槽在卡中添加可选的 header
/footer
。
您可以通过设置 header-tag
和 footer-tag
属性来控制使用的包装器元素标签( 默认均为 div
)
混合和匹配多种内容类型来创建您需要的卡片,或者将所有内容都放入其中。下面显示的是图像样式、块、文本样式和列表组—所有这些都包装在固定宽度的卡片中。
Some quick example text to build on the card title and make up the bulk of the card's content.
使用网格(grid)组件、实用程序类和单个卡片子组件的组合,可以使卡片以便于移动和响应的方式水平放置。
在下面的示例中,我们使用 <b-row>
上的 no-gutters
属性删除行网格装订线,并使用 <b-col>
上的 md
属性将卡片水平放置在 md
断点处。rounded-0
类将除去 <b-card-img>
的圆角,而 <b-card>
上的 overflow-hidden
将根据卡片的 border-radius 适当地裁剪图像的角。根据您的卡片内容,可能需要进一步调整。
This is a wider card with supporting text as a natural lead-in to additional content. This content is a little bit longer.
默认情况下,卡片使用深色文字并采用浅色背景。 您可以通过 text-variant
属性切换文本以及卡的子组件的颜色来反转颜色。 然后,指定深色背景变体。
卡片包含自己的变量样式,可通过 bg-variant
和 border-variant
属性快速更改背景颜色以及卡片的颜色。较暗的实体变量我需要设置 text-variant
属性来调整文本颜色。
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
BootstrapVue <b-card>
变量直接映射到 Bootstrap v4
卡片类,通过预先挂起的 bg-
(对于 solid) 或 border-
(对于 bordered) 映射到上述变量名。
您还可以通过 header-bg-variant
, header-border-variant
, header-text-variant
, footer-bg-variant
, footer-border-variant
,和 footer-text-variant
属性将 solid 和 border 变量应用于卡片的页眉和页脚和和页脚变量
使用颜色添加含义仅提供视觉指示,而不会传达给辅助技术的用户(例如屏幕阅读器)。 确保用颜色表示的信息从内容本身来看是显而易见的(例如,可见文本),或者通过其他方式包括在其中,例如用 .sr-only
类隐藏的其他文本。
将 <b-nav>
轻松集成到卡片页眉中。
使用(页眉) header
插槽:
With supporting text below as a natural lead-in to additional content.
使用 <b-card-header>
子组件:
With supporting text below as a natural lead-in to additional content.
有关在卡片页眉中使用 <b-nav>
的更多信息,请参阅 导航文档 。
In addition to styling the content within cards, BootstrapVue includes a <b-card-group>
component
for laying out series of cards. For the time being, these layout options are not yet responsive.
Use card groups to render cards as a single, attached element with equal width and height columns. Card groups use display: flex; to achieve their uniform sizing.
When using card groups with footers, their content will automatically line up.
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
This card has supporting text below as a natural lead-in to additional content.
This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.
Need a set of equal width and height cards that aren't attached to one another? Use card decks by
setting the deck
prop. And just like with regular
card groups, card footers in decks will
automatically line up.
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
This card has supporting text below as a natural lead-in to additional content.
This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.
Cards can be organized into Masonry-like columns with by wrapping them in a <b-card-group>
with
the prop columns
set. Cards are built with CSS
column properties instead of flexbox for easier
alignment. Cards are ordered from top to bottom and left to right.
Heads up! Your mileage with card columns may vary. To prevent cards breaking across columns, we must set them to display: inline-block as column-break-inside: avoid isn't a bulletproof solution yet.
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
This card has supporting text below as a natural lead-in to additional content.
Last updated 3 mins ago
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
This card has supporting text below as a natural lead-in to additional content.
Last updated 3 mins ago
This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first.
<b-card>
Property (Click to sort Ascending) | Type | Default | Description |
---|---|---|---|
body-tag |
String | 'div' |
Specify the HTML tag to render instead of the default tag for the body |
body-bg-variant |
String | Applies one of the Bootstrap theme color variants to the body background | |
body-border-variant |
String | Applies one of the Bootstrap theme color variants to the body border | |
body-text-variant |
String | Applies one of the Bootstrap theme color variants to the body text | |
body-class |
String or Object or Array | CSS class (or classes) to apply to the body | |
title |
String | Text content to place in the title | |
title-tag |
String | 'h4' |
Specify the HTML tag to render instead of the default tag for the title |
sub-title |
String | Text content to place in the sub title | |
sub-title-tag |
String | 'h6' |
Specify the HTML tag to render instead of the default tag for the sub title |
sub-title-text-variant |
String | 'muted' |
Applies one of the Bootstrap theme color variants to the sub title text |
overlay |
Boolean | false |
When set, will overlay the card body on top of the image (if the card has an image) |
header-tag |
String | 'div' |
Specify the HTML tag to render instead of the default tag for the header |
header-bg-variant |
String | Applies one of the Bootstrap theme color variants to the header background | |
header-border-variant |
String | Applies one of the Bootstrap theme color variants to the header border | |
header-text-variant |
String | Applies one of the Bootstrap theme color variants to the header text | |
header |
String | Text content to place in the header | |
header-html Use with caution |
String | HTML string content to place in the header. Use with caution | |
header-class |
String or Object or Array | CSS class (or classes) to apply to the header | |
footer-tag |
String | 'div' |
Specify the HTML tag to render instead of the default tag for the footer |
footer-bg-variant |
String | Applies one of the Bootstrap theme color variants to the footer background | |
footer-border-variant |
String | Applies one of the Bootstrap theme color variants to the footer border | |
footer-text-variant |
String | Applies one of the Bootstrap theme color variants to the footer text | |
footer |
String | Text content to place in the footer | |
footer-html Use with caution |
String | HTML string content to place in the footer. Use with caution | |
footer-class |
String or Object or Array | CSS class (or classes) to apply to the footer | |
img-src |
String | URL for the optional image | |
img-alt |
String | Value to set the image attribute 'alt' | |
img-top |
Boolean | false |
Set if the image should appear at the top of the card |
img-bottom |
Boolean | false |
Set if the image should appear at the bottom of the card |
img-start |
Boolean | false |
Set if the image should appear at the start (left) of the card |
img-left |
Boolean | false |
Set if the image should appear at the start (left) of the card. Synonym for the 'left' prop |
img-end |
Boolean | false |
Set if the image should appear at the end (right) of the card |
img-right |
Boolean | false |
Set if the image should appear at the end (right) of the card. Synonym for the 'right' prop |
img-height |
Number or String | The value to set on the image's 'height' attribute | |
img-width |
Number or String | The value to set on the image's 'width' attribute | |
tag |
String | 'div' |
Specify the HTML tag to render instead of the default tag |
bg-variant |
String | Applies one of the Bootstrap theme color variants to the background | |
border-variant |
String | Applies one of the Bootstrap theme color variants to the border | |
text-variant |
String | Applies one of the Bootstrap theme color variants to the text | |
align |
String | Text alignment for the card's content: 'left', 'center' or 'right' | |
no-body |
Boolean | false |
Disable rendering of the default inner card-body element |
Caution: Props that support
HTML strings
(*-html
) can be vulnerable to Cross Site Scripting (XSS)
attacks when passed raw user supplied values. You must properly sanitize the user input first!
Slot Name | Description |
---|---|
header |
For custom rendering of header content |
footer |
For custom rendering of footer content |
<b-card-header>
Property | Type | Default | Description |
---|---|---|---|
header-tag |
String | 'div' |
Specify the HTML tag to render instead of the default tag for the header |
header-bg-variant |
String | Applies one of the Bootstrap theme color variants to the header background | |
header-border-variant |
String | Applies one of the Bootstrap theme color variants to the header border | |
header-text-variant |
String | Applies one of the Bootstrap theme color variants to the header text | |
header |
String | Text content to place in the header | |
header-html Use with caution |
String | HTML string content to place in the header. Use with caution | |
header-class |
String or Object or Array | CSS class (or classes) to apply to the header |
Caution: Props that support
HTML strings
(*-html
) can be vulnerable to Cross Site Scripting (XSS)
attacks when passed raw user supplied values. You must properly sanitize the user input first!
<b-card-footer>
Property | Type | Default | Description |
---|---|---|---|
footer-tag |
String | 'div' |
Specify the HTML tag to render instead of the default tag for the footer |
footer-bg-variant |
String | Applies one of the Bootstrap theme color variants to the footer background | |
footer-border-variant |
String | Applies one of the Bootstrap theme color variants to the footer border | |
footer-text-variant |
String | Applies one of the Bootstrap theme color variants to the footer text | |
footer |
String | Text content to place in the footer | |
footer-html Use with caution |
String | HTML string content to place in the footer. Use with caution | |
footer-class |
String or Object or Array | CSS class (or classes) to apply to the footer |
Caution: Props that support
HTML strings
(*-html
) can be vulnerable to Cross Site Scripting (XSS)
attacks when passed raw user supplied values. You must properly sanitize the user input first!
<b-card-body>
Property (Click to sort Ascending) | Type | Default | Description |
---|---|---|---|
body-tag |
String | 'div' |
Specify the HTML tag to render instead of the default tag for the body |
body-bg-variant |
String | Applies one of the Bootstrap theme color variants to the body background | |
body-border-variant |
String | Applies one of the Bootstrap theme color variants to the body border | |
body-text-variant |
String | Applies one of the Bootstrap theme color variants to the body text | |
body-class |
String or Object or Array | CSS class (or classes) to apply to the body | |
title |
String | Text content to place in the title | |
title-tag |
String | 'h4' |
Specify the HTML tag to render instead of the default tag for the title |
sub-title |
String | Text content to place in the sub title | |
sub-title-tag |
String | 'h6' |
Specify the HTML tag to render instead of the default tag for the sub title |
sub-title-text-variant |
String | 'muted' |
Applies one of the Bootstrap theme color variants to the sub title text |
overlay |
Boolean | false |
When set, will overlay the card body on top of the image (if the card has an image) |
<b-card-title>
Property | Type | Default | Description |
---|---|---|---|
title |
String | Text content to place in the title | |
title-tag |
String | 'h4' |
Specify the HTML tag to render instead of the default tag for the title |
<b-card-sub-title>
Property | Type | Default | Description |
---|---|---|---|
sub-title |
String | Text content to place in the sub title | |
sub-title-tag |
String | 'h6' |
Specify the HTML tag to render instead of the default tag for the sub title |
sub-title-text-variant |
String | 'muted' |
Applies one of the Bootstrap theme color variants to the sub title text |
<b-card-img>
Property (Click to sort Ascending) | Type | Default | Description |
---|---|---|---|
src Required |
String | URL to set for the 'src' attribute | |
alt |
String | Value to set for the 'alt' attribute | |
top |
Boolean | false |
Set if the image will be placed at the top of the card |
bottom |
Boolean | false |
Set if the image will be placed at the bottom of the card |
start |
Boolean | false |
Set if the image will be placed at the start (left) of the card |
left |
Boolean | false |
Set if the image will be placed at the start (left) of the card. Synonym for the 'left' prop |
end |
Boolean | false |
Set if the image will be placed at the end (right) of the card |
right |
Boolean | false |
Set if the image will be placed at the end (right) of the card. Synonym for the 'right' prop |
height |
Number or String | The value to set on the image's 'height' attribute | |
width |
Number or String | The value to set on the image's 'width' attribute |
<b-card-img-lazy>
Property (Click to sort Ascending) | Type | Default | Description |
---|---|---|---|
src Required |
String | URL to set for the 'src' attribute | |
srcset |
String or Array | ||
sizes |
String or Array | ||
alt |
String | Value to set for the 'alt' attribute | |
width |
Number or String | The value to set on the image's 'width' attribute | |
height |
Number or String | The value to set on the image's 'height' attribute | |
blank-src |
String | URL of placeholder image. If not set, an SVG placeholder placeholder will be used | |
blank-color |
String | 'transparent' |
CSS color of the blank SVG placeholder image. Has no effect if 'blank-src' is set |
blank-width |
Number or String | Value of the 'width' attribute for the placeholder image | |
blank-height |
Number or String | Value of the 'height' attribute for the placeholder image | |
show |
Boolean | false |
If set to true, will force show the image specified via the 'src' prop |
offset |
Number or String | 360 |
Number of pixels away from the viewport edge before the lazy image is loaded |
top |
Boolean | false |
Set if the image will be placed at the top of the card |
bottom |
Boolean | false |
Set if the image will be placed at the bottom of the card |
start |
Boolean | false |
Set if the image will be placed at the start (left) of the card |
left |
Boolean | false |
Set if the image will be placed at the start (left) of the card. Synonym for the 'left' prop |
end |
Boolean | false |
Set if the image will be placed at the end (right) of the card |
right |
Boolean | false |
Set if the image will be placed at the end (right) of the card. Synonym for the 'right' prop |
<b-card-text>
Property | Type | Default | Description |
---|---|---|---|
text-tag |
String | 'p' |
Specify the HTML tag to render instead of the default tag for the text content |
<b-card-group>
Property | Type | Default | Description |
---|---|---|---|
tag |
String | 'div' |
Specify the HTML tag to render instead of the default tag |
deck |
Boolean | false |
When set renders the card group with gutters between cards |
columns |
Boolean | false |
When set, renders the card group in a masonry-like columnar style |
You can import individual components into your project via the following named exports:
Component | Named Export | Import Path |
---|---|---|
<b-card> |
BCard |
bootstrap-vue |
<b-card-header> |
BCardHeader |
bootstrap-vue |
<b-card-footer> |
BCardFooter |
bootstrap-vue |
<b-card-body> |
BCardBody |
bootstrap-vue |
<b-card-title> |
BCardTitle |
bootstrap-vue |
<b-card-sub-title> |
BCardSubTitle |
bootstrap-vue |
<b-card-img> |
BCardImg |
bootstrap-vue |
<b-card-img-lazy> |
BCardImgLazy |
bootstrap-vue |
<b-card-text> |
BCardText |
bootstrap-vue |
<b-card-group> |
BCardGroup |
bootstrap-vue |
Example:
This plugin includes all of the above listed individual components. Plugins also include any component aliases.
Named Export | Import Path |
---|---|
CardPlugin |
bootstrap-vue |
Example: