Skip to content

Bootstrap4 - Inverted colors on a Card isn't inverting the list-group within.  #22907

Closed

Description

@lazharichir

Hello - I have a card showing a list of items as a List-Group.

The card is inverted with the warning colors:

				<div class="col-12 col-md-3 flex-first">
					<div class="card p-0 card-inverse card-warning">
					  <div class="card-block">
					    <h4 class="card-title">At a Glance</h4>
					    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
					    <a href="#" class="card-link">Card link</a>
					    <a href="#" class="card-link">Another link</a>
					  </div>
					  <ul class="list-group list-group-flush list-group-inverse">
					    <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>
				</div>

But here is how it looks:

screen shot 2017-06-25 at 17 58 47

The list-group-items aren't inverted themselves so they cannot be seen.

Activity

  1. asyncdesign commented on Jun 25, 2017

    @asyncdesign

    I assume you don't want the list items in the bottom section to be white with an orange background, so put the card-inverse class on the card block not the card, and you don't need the list-group-inverse class for the list group.

    In any case, the margin: -1px / border 1px combination (used on list items) is inherently unstable at various zoom levels, and leads to visual anomalies such as disappearing borders - that's a bug in Bootstrap.

  2. added
    cssSass sources or compiled CSS
    v4v4, the frozen docs on gh-pages
    on Jun 26, 2017
  3. TheHokieCoder commented on Jun 29, 2017

    @TheHokieCoder

    In general, list groups are meant to have their own control of background colors instead of inheriting like the inner elements of a card do (see the list groups documentation). A quick fix is to embrace this and add .list-group-item-warning to each li in your list group, which will give the light orange background and appropriate text color (BTW, I don't believe .list-group-inverse class exists as I couldn't find it in the source. It appears the .list-group-item-* classes take care of the foreground color for you.). If you want the list group's background color to match the card color variant, you will need to do some custom CSS for that. Alternatively, the devs could decide to add extra CSS for the case where a list group is a child of a .card to do one of the following:

    1. inherit the background color from the parent for non-active states (not sure how you would handle the hover state, though, since that probably can't be inherited)
    2. specify the "bold" background colors for the variants at the expense of losing the light background color variants that should be expected for list groups
    3. some other solution that I'm not thinking of

    As far as the border issue goes that asyncdesign mentioned, I'm not sure how to fix that or even why there is a -1px margin on the list groups (I didn't really delve into those styles, only a cursory glance).

  4. mdo commented on Jun 30, 2017

    @mdo
    Member

    This is going to be changed with #22950. The .card-inverse class is gone and there are new ways to style cards with different utilities, as opposed to dedicated card modifier classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cssSass sources or compiled CSSv4v4, the frozen docs on gh-pages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions