Bootstrap: Cards in .card-deck do not always have same width

Created on 31 Mar 2016  路  8Comments  路  Source: twbs/bootstrap

This is with respect to bootstrap v4.
Here is a link to reproduce the issue:
http://paradite.github.io/d3card/

By clicking the buttons to change to font size of the card-title, the cards will either have equal width or unequal width. I believe the correct behaviour should be that cards always have equal width.

A possible reason may be due to the image size, but then again the whole point of the card deck is to dynamically fit the image into the cards and fit the cards into the screen I believe.

OS: OS X 10.11.3
Browser: Chrome 49.0.2623.87

confirmed css v4

Most helpful comment

Work for me:

.card-deck {
    width: 100%;
}

But why it work????

All 8 comments

Confirmed.
CC: @mdo

I think I found the cause of the issue, it is the width: 1% inside .card-deck .card

I was able to fix the issue by using

.card-deck .card {
    width: initial;
}

Work for me:

.card-deck {
    width: 100%;
}

But why it work????

My guess as to why this works is because <table> cells (by default) resize depending on the content that is inside (if a width is not defined).

However with a "reset" style like width: 100%, it forces all of them to be the same width.

Similar to in flexbox if you did flex: 1 to children elements of a parent with display: flex.

I have a problem with the card-deck, he is breaking the width of the size of the body / html, creating horizontal scrolling, following image and test html

<!DOCTYPE html> <html lang="pt-br"> <head> <title>test nivo</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css"> </head> <body> <div class="card-deck-wrapper"> <div class="card-deck"> <div class="card"> <div class="card-block"> Card 1 </div> </div> <div class="card"> <div class="card-block"> Card 2 </div> </div> <div class="card"> <div class="card-block"> Card 3 </div> </div> <div class="card"> <div class="card-block"> Card 4 </div> </div> </div> </div> <script src="https://code.jquery.com/jquery-2.2.3.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js"></script> </body> </html>

card-deck-size-problem

@rubenscd That should have been opened as a separate issue, but I see the problem: all the content in the <body> should be wrapped in a <div> with .container or .container-fluid.

@RyanZim thanks, I will open in another task, but with .container-fluid same problem.

Improvements coming in #19885.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

devdelimited picture devdelimited  路  3Comments

devfrey picture devfrey  路  3Comments

kamov picture kamov  路  3Comments

alvarotrigo picture alvarotrigo  路  3Comments

fohlsom picture fohlsom  路  3Comments