cards.md 4.5 KB
Newer Older
C
chomik 已提交
1 2
---
title: Cards
C
chomik 已提交
3
menu: docs.cards
C
chomik 已提交
4
description: A card is a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options. 
C
codecalm 已提交
5
bootstrap-link: components/card/
C
codecalm 已提交
6
done: true
C
codecalm 已提交
7
toc: true
C
chomik 已提交
8 9 10 11
---

The `.card` element is simply a container with a shadow, a border, a radius, and some padding. Built with flexbox, they offer easy alignment and mix well with other Bootstrap components.

C
codecalm 已提交
12 13 14
## Default card

To create a new card you have to use the `.card` and `.card-body` classes. You can put any content inside. 
C
chomik 已提交
15

C
codecalm 已提交
16
{% capture code %}
C
codecalm 已提交
17
{% include cards/card.html body="This is some text within a card body." %}
C
codecalm 已提交
18
{% endcapture %}
C
codecalm 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
{% include example.html code=code columns=1 %}

### Card padding

You can change the padding of a newly created card. You can do this with the `.card-sm`, `.card-md` and `.card-lg` classes. 

Cards with the `.card-sm` class are very well suited for small items such as snippets, etc., while `.card-lg` can be used for large blocks of text. On small devices, padding will automatically be reduced to fit on the screen.

{% capture code %}
{% include cards/card.html class="card-sm" body="This is some text within a card body." %}
{% include cards/card.html body="This is some text within a card body." %}
{% include cards/card.html class="card-md" body="This is some text within a card body." %}
{% include cards/card.html class="card-lg" body="This is some text within a card body." %}
{% endcapture %}
{% include example.html code=code columns=2 %}
C
chomik 已提交
34

C
codecalm 已提交
35 36 37 38 39 40 41 42 43 44 45 46 47
## Card with title

To add a title to a card you should add a class `.card-title` inside `.card-body`.

You can also place the title inside the `.card-header` element - then the title will be separated from the content by a horizontal line.

{% capture code %}
{% include cards/card.html title="Card title" body="This is some text within a card body." %}
{% include cards/card.html header-title="Card title" body="This is some text within a card body." %}
{% endcapture %}
{% include example.html code=code columns=1 %}

## Card with title and image
C
chomik 已提交
48

C
codecalm 已提交
49
{% capture code %}
C
codecalm 已提交
50
{% include cards/card.html img-top=true title="Card with title and image" %}
C
codecalm 已提交
51
{% endcapture %}
C
codecalm 已提交
52 53 54
{% include example.html code=code columns=1 %}

## Blog post card
C
chomik 已提交
55 56 57

The best way to make your post eye-catching is adding an image to it. To do so, just add the image with the `.card-img-top` class. We've added the `.d-flex .flex-column` classes to the `.card-body` to have the author details be on the bottom of the card.

C
codecalm 已提交
58
{% capture code %}
C
codecalm 已提交
59
{% include cards/blog-single.html type="image" %}
C
codecalm 已提交
60
{% endcapture %}
C
codecalm 已提交
61
{% include example.html code=code columns=1 %}
C
chomik 已提交
62

C
codecalm 已提交
63
## Row deck
C
chomik 已提交
64 65 66

If you want to create a couple of posts next to each other, add the `.row-deck` class to `.row`—then they will all have the same height.

C
codecalm 已提交
67
{% capture code %}
68
<div class="row row-deck">
C
chomik 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
    <div class="col-md-4">
        <div class="card">
            <div class="card-body">Short content</div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card">
            <div class="card-body">Extra long content of card. Lorem ipsum dolor sit amet, consetetur sadipscing elitr</div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card">
            <div class="card-body">Short content</div>
        </div>
    </div>
</div>
C
codecalm 已提交
85
{% endcapture %}
C
codecalm 已提交
86
{% include example.html code=code columns=2 %}
C
chomik 已提交
87

C
codecalm 已提交
88
## Post card with aside image
C
chomik 已提交
89 90 91

You can also add the image on the left side of the card. All you need do to is: add the `.card-aside` class to the element with the `.card` class. Then add the image in the `.card-aside-column` element. No worries, tabler will automatically center it and scale to right size:

C
codecalm 已提交
92
{% capture code %}
C
codecalm 已提交
93
{% include cards/blog-single.html type="aside" liked=1 article-id=3 %}
C
codecalm 已提交
94
{% endcapture %}
C
codecalm 已提交
95
{% include example.html code=code columns=2 %}
C
chomik 已提交
96

C
codecalm 已提交
97
## Color variations
C
chomik 已提交
98

C
codecalm 已提交
99
{% capture code %}
100
<div class="row row-deck">
C
codecalm 已提交
101
    <div class="col-md-6">
C
codecalm 已提交
102
        {% include cards/card.html status-top="danger" title="Card with top status" %}
M
mrszympek 已提交
103
    </div>
C
codecalm 已提交
104
    <div class="col-md-6">
C
codecalm 已提交
105
        {% include cards/card.html status-left="green" title="Card with side status" %}
C
chomik 已提交
106 107
    </div>
</div>
C
codecalm 已提交
108
{% endcapture %}
C
codecalm 已提交
109
{% include example.html code=code columns=2 %}
C
chomik 已提交
110

C
codecalm 已提交
111
## Stacked card
C
chomik 已提交
112

C
codecalm 已提交
113
{% capture code %}
C
codecalm 已提交
114
{% include cards/card.html class="card-stacked" title="Stacked card" %}
C
codecalm 已提交
115
{% endcapture %}
C
codecalm 已提交
116
{% include example.html code=code columns=1 %}
M
mrszympek 已提交
117

C
codecalm 已提交
118
## Tabbed card
M
mrszympek 已提交
119

C
codecalm 已提交
120
{% capture code %}
C
codecalm 已提交
121
{% include cards/card-tabs.html count=4 %}
C
codecalm 已提交
122
{% endcapture %}
C
codecalm 已提交
123
{% include example.html code=code columns=2 %}
M
mrszympek 已提交
124