_card.scss 5.63 KB
Newer Older
Mark Otto's avatar
cards  
Mark Otto committed
1
2
3
4
5
6
//
// Base styles
//

.card {
  position: relative;
Mark Otto's avatar
Mark Otto committed
7
8
  display: flex;
  flex-direction: column;
9
  min-width: 0; // See https://github.com/twbs/bootstrap/pull/22740#issuecomment-305868106
10
  word-wrap: break-word;
11
  background-color: $card-bg;
12
  background-clip: border-box;
Mark Otto's avatar
Mark Otto committed
13
  border: $card-border-width solid $card-border-color;
14
  @include border-radius($card-border-radius);
15
16
17
18
19

  > hr {
    margin-right: 0;
    margin-left: 0;
  }
20
21
22
23
24
25
26
27
28
29
30
31

  > .list-group:first-child {
    .list-group-item:first-child {
      @include border-top-radius($card-border-radius);
    }
  }

  > .list-group:last-child {
    .list-group-item:last-child {
      @include border-bottom-radius($card-border-radius);
    }
  }
32
33
}

34
.card-body {
35
36
37
  // Enable `flex-grow: 1` for decks and groups so that card blocks take up
  // as much space as possible, ensuring footers are aligned to the bottom.
  flex: 1 1 auto;
38
39
40
  // Workaround for the image size bug in IE
  // See: https://github.com/twbs/bootstrap/pull/28855
  min-height: 1px;
41
  padding: $card-spacer-x;
42
  color: $card-color;
Mark Otto's avatar
cards  
Mark Otto committed
43
}
44

Mark Otto's avatar
cards  
Mark Otto committed
45
.card-title {
46
  margin-bottom: $card-spacer-y;
Mark Otto's avatar
cards  
Mark Otto committed
47
}
48
49

.card-subtitle {
50
  margin-top: -$card-spacer-y / 2;
Mark Otto's avatar
cards  
Mark Otto committed
51
52
  margin-bottom: 0;
}
53
54
55

.card-text:last-child {
  margin-bottom: 0;
Mark Otto's avatar
cards  
Mark Otto committed
56
}
57

58
.card-link {
Mark Otto's avatar
Mark Otto committed
59
  &:hover {
60
61
    text-decoration: none;
  }
Mark Otto's avatar
cards  
Mark Otto committed
62

63
64
65
66
  + .card-link {
    margin-left: $card-spacer-x;
  }
}
Mark Otto's avatar
cards  
Mark Otto committed
67

Mark Otto's avatar
Mark Otto committed
68
//
69
// Optional textual caps
Mark Otto's avatar
Mark Otto committed
70
71
//

72
73
.card-header {
  padding: $card-spacer-y $card-spacer-x;
74
  margin-bottom: 0; // Removes the default margin-bottom of <hN>
75
  color: $card-cap-color;
76
  background-color: $card-cap-bg;
Mark Otto's avatar
Mark Otto committed
77
  border-bottom: $card-border-width solid $card-border-color;
Mark Otto's avatar
Mark Otto committed
78

79
  &:first-child {
80
    @include border-radius($card-inner-border-radius $card-inner-border-radius 0 0);
81
  }
82
83
84
85
86
87

  + .list-group {
    .list-group-item:first-child {
      border-top: 0;
    }
  }
Mark Otto's avatar
Mark Otto committed
88
89
}

90
91
.card-footer {
  padding: $card-spacer-y $card-spacer-x;
92
  background-color: $card-cap-bg;
Mark Otto's avatar
Mark Otto committed
93
  border-top: $card-border-width solid $card-border-color;
94
95

  &:last-child {
96
    @include border-radius(0 0 $card-inner-border-radius $card-inner-border-radius);
97
  }
Mark Otto's avatar
Mark Otto committed
98
99
100
}


101
102
103
104
105
//
// Header navs
//

.card-header-tabs {
106
  margin-right: -$card-spacer-x / 2;
107
  margin-bottom: -$card-spacer-y;
108
  margin-left: -$card-spacer-x / 2;
109
  border-bottom: 0;
110
111
112
113
114
115
116

  @if $nav-tabs-link-active-bg != $card-bg {
    .nav-link.active {
      background-color: $card-bg;
      border-bottom-color: $card-bg;
    }
  }
117
118
119
}

.card-header-pills {
120
121
  margin-right: -$card-spacer-x / 2;
  margin-left: -$card-spacer-x / 2;
122
123
}

Mark Otto's avatar
cards  
Mark Otto committed
124
125
126
127
128
129
130
// Card image
.card-img-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
131
  padding: $card-img-overlay-padding;
Mark Otto's avatar
cards  
Mark Otto committed
132
133
}

Mark Otto's avatar
Mark Otto committed
134
135
.card-img {
  width: 100%; // Required because we use flexbox and this inherently applies align-self: stretch
136
  @include border-radius($card-inner-border-radius);
Mark Otto's avatar
Mark Otto committed
137
}
Mark Otto's avatar
cards  
Mark Otto committed
138
139
140

// Card image caps
.card-img-top {
Mark Otto's avatar
Mark Otto committed
141
  width: 100%; // Required because we use flexbox and this inherently applies align-self: stretch
142
  @include border-top-radius($card-inner-border-radius);
Mark Otto's avatar
cards  
Mark Otto committed
143
}
Mark Otto's avatar
Mark Otto committed
144

Mark Otto's avatar
cards  
Mark Otto committed
145
.card-img-bottom {
Mark Otto's avatar
Mark Otto committed
146
  width: 100%; // Required because we use flexbox and this inherently applies align-self: stretch
147
  @include border-bottom-radius($card-inner-border-radius);
Mark Otto's avatar
cards  
Mark Otto committed
148
149
150
}


151
// Card deck
Mark Otto's avatar
cards  
Mark Otto committed
152

153
154
155
156
157
158
159
160
161
.card-deck {
  display: flex;
  flex-direction: column;

  .card {
    margin-bottom: $card-deck-margin;
  }

  @include media-breakpoint-up(sm) {
162
    flex-flow: row wrap;
Mark Otto's avatar
Mark Otto committed
163
164
    margin-right: -$card-deck-margin;
    margin-left: -$card-deck-margin;
165
166

    .card {
167
      display: flex;
168
      // Flexbugs #4: https://github.com/philipwalton/flexbugs#flexbug-4
169
      flex: 1 0 0%;
170
      flex-direction: column;
Mark Otto's avatar
Mark Otto committed
171
      margin-right: $card-deck-margin;
172
      margin-bottom: 0; // Override the default
Mark Otto's avatar
Mark Otto committed
173
      margin-left: $card-deck-margin;
174
175
176
    }
  }
}
Mark Otto's avatar
cards  
Mark Otto committed
177

178

Mark Otto's avatar
cards  
Mark Otto committed
179
180
181
182
//
// Card groups
//

183
184
185
186
.card-group {
  display: flex;
  flex-direction: column;

187
188
189
  // The child selector allows nested `.card` within `.card-group`
  // to display properly.
  > .card {
190
191
192
193
    margin-bottom: $card-group-margin;
  }

  @include media-breakpoint-up(sm) {
194
    flex-flow: row wrap;
195
196
197
    // The child selector allows nested `.card` within `.card-group`
    // to display properly.
    > .card {
198
      // Flexbugs #4: https://github.com/philipwalton/flexbugs#flexbug-4
199
      flex: 1 0 0%;
200
      margin-bottom: 0;
201

202
203
204
      + .card {
        margin-left: 0;
        border-left: 0;
205
      }
206
207
208

      // Handle rounded corners
      @if $enable-rounded {
209
        &:not(:last-child) {
210
211
          @include border-right-radius(0);

212
213
          .card-img-top,
          .card-header {
214
            // stylelint-disable-next-line property-blacklist
215
216
            border-top-right-radius: 0;
          }
217
218
          .card-img-bottom,
          .card-footer {
219
            // stylelint-disable-next-line property-blacklist
220
221
            border-bottom-right-radius: 0;
          }
222
        }
223

224
        &:not(:first-child) {
225
          @include border-left-radius(0);
226

227
228
          .card-img-top,
          .card-header {
229
            // stylelint-disable-next-line property-blacklist
230
231
            border-top-left-radius: 0;
          }
232
233
          .card-img-bottom,
          .card-footer {
234
            // stylelint-disable-next-line property-blacklist
235
236
            border-bottom-left-radius: 0;
          }
237
238
239
        }
      }
    }
Mark Otto's avatar
cards  
Mark Otto committed
240
241
242
243
  }
}


Andres Galante's avatar
Andres Galante committed
244
245
246
247
248
//
// Accordion
//

.accordion {
249
  > .card {
250
251
252
253
    overflow: hidden;

    &:not(:first-of-type) {
      .card-header:first-child {
254
        @include border-radius(0);
255
      }
Andres Galante's avatar
Andres Galante committed
256

257
258
      &:not(:last-of-type) {
        border-bottom: 0;
259
        @include border-radius(0);
260
      }
Andres Galante's avatar
Andres Galante committed
261
262
    }

263
    &:first-of-type:not(:last-of-type) {
264
      border-bottom: 0;
265
      @include border-bottom-radius(0);
266
    }
Andres Galante's avatar
Andres Galante committed
267

268
    &:last-of-type {
269
      @include border-top-radius(0);
270
271
272
273
274
    }

    .card-header {
      margin-bottom: -$card-border-width;
    }
Andres Galante's avatar
Andres Galante committed
275
276
  }
}