]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Simplify list-group borders in cards (#30808)
authorMark Otto <markd.otto@gmail.com>
Thu, 14 May 2020 17:48:46 +0000 (10:48 -0700)
committerXhmikosR <xhmikosr@gmail.com>
Thu, 4 Jun 2020 14:53:16 +0000 (17:53 +0300)
scss/_card.scss
site/docs/4.5/components/card.md

index fabe9f3676025227ad9f98b7e1ab5a78f6266206..5ec2bcbeaf20221a40c1d1b9c9f5fb7e88042b83 100644 (file)
       @include border-bottom-radius($card-inner-border-radius);
     }
   }
+
+  // Due to specificity of the above selector (`.card > .list-group`), we must
+  // use a child selector here to prevent double borders.
+  > .card-header + .list-group,
+  > .list-group + .card-footer {
+    border-top: 0;
+  }
 }
 
 .card-body {
   &:first-child {
     @include border-radius($card-inner-border-radius $card-inner-border-radius 0 0);
   }
-
-  + .list-group {
-    .list-group-item:first-child {
-      border-top: 0;
-    }
-  }
 }
 
 .card-footer {
index b234eeaa5aa2eac9415664eba74807e71235ebb7..18e1c0fabb4c61cf43548e7dfcb2aadd8d119073 100644 (file)
@@ -107,6 +107,20 @@ Create lists of content in a card with a flush list group.
 {% endcapture %}
 {% include example.html content=example %}
 
+{% capture example %}
+<div class="card" style="width: 18rem;">
+  <ul class="list-group list-group-flush">
+    <li class="list-group-item">Cras justo odio</li>
+    <li class="list-group-item">Dapibus ac facilisis in</li>
+    <li class="list-group-item">Vestibulum at eros</li>
+  </ul>
+  <div class="card-footer">
+    Card footer
+  </div>
+</div>
+{% endcapture %}
+{% include example.html content=example %}
+
 ### Kitchen sink
 
 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.