I am trying to use a card-deck
in bootstrap 4 which contain cards with different width.
For single cards you do the following to change the width (or use class w-25
, w-50
or w-75
if the 25%, 50% or 75% width fit your needs):
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="card">
<div class="card-header">Header</div>
<div class="card-body">
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisici elit.</p>
</div>
</div>
<br>
<div class="card" style="width: 30%">
<div class="card-header">Header</div>
<div class="card-body">
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisici elit.</p>
</div>
</div>
<br>
<div class="card" style="width: 70%">
<div class="card-header">Header</div>
<div class="card-body">
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisici elit.</p>
</div>
</div>
</div>
For a card-deck
containing cards with equal width you do this:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<h1>Card Deck with equal width</h1>
<div class="card-deck">
<div class="card">
<div class="card-header">Header</div>
<div class="card-body">
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisici elit.</p>
</div>
</div>
<div class="card">
<div class="card-header">Header</div>
<div class="card-body">
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisici elit.</p>
</div>
</div>
</div>
<br>
</div>
To have a card-deck
containing cards with different width I tried this (without success):
Note: The cards are displayed with equal width even that they have different width...
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="card-deck">
<div class="card" style="width: 30%">
<div class="card-header">Header</div>
<div class="card-body">
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisici elit.</p>
</div>
</div>
<div class="card" style="width: 70%">
<div class="card-header">Header</div>
<div class="card-body">
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisici elit.</p>
</div>
</div>
</div>
</div>
so obviously I'm doing something wrong here (or bootstrap 4 is not supporting this). any suggestions how to use a card-deck
containing cards with different width?