Skip to content

Commit 233a659

Browse files
mdoXhmikosR
authored andcommitted
Simplify list-group borders in cards (#30808)
1 parent 4e685e7 commit 233a659

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

scss/_card.scss

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
@include border-bottom-radius($card-inner-border-radius);
3434
}
3535
}
36+
37+
// Due to specificity of the above selector (`.card > .list-group`), we must
38+
// use a child selector here to prevent double borders.
39+
> .card-header + .list-group,
40+
> .list-group + .card-footer {
41+
border-top: 0;
42+
}
3643
}
3744

3845
.card-body {
@@ -83,12 +90,6 @@
8390
&:first-child {
8491
@include border-radius($card-inner-border-radius $card-inner-border-radius 0 0);
8592
}
86-
87-
+ .list-group {
88-
.list-group-item:first-child {
89-
border-top: 0;
90-
}
91-
}
9293
}
9394

9495
.card-footer {

site/docs/4.5/components/card.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ Create lists of content in a card with a flush list group.
107107
{% endcapture %}
108108
{% include example.html content=example %}
109109

110+
{% capture example %}
111+
<div class="card" style="width: 18rem;">
112+
<ul class="list-group list-group-flush">
113+
<li class="list-group-item">Cras justo odio</li>
114+
<li class="list-group-item">Dapibus ac facilisis in</li>
115+
<li class="list-group-item">Vestibulum at eros</li>
116+
</ul>
117+
<div class="card-footer">
118+
Card footer
119+
</div>
120+
</div>
121+
{% endcapture %}
122+
{% include example.html content=example %}
123+
110124
### Kitchen sink
111125

112126
Mix and match multiple content types to create the card you need, or throw everything in there. Shown below are image styles, blocks, text styles, and a list group—all wrapped in a fixed-width card.

0 commit comments

Comments
 (0)