I thought what I'm trying to do would be pretty easy to do but I just can't make it work.
I tried to do pull-left on bootstrap cards and panels and it's not working the way I want it to...
Here is a picture of what I'd like to acheive
Example
Heres code that almost works
<div class="card text-center" *ngFor="let event of eventActivities"> <div class="card-header pull-left"> <img src="..." alt=""> Title </div> <div class="card-block"> <h4 class="card-title">Title</h4> <p class="card-text">Description</p> <a href="#" class="btn btn-primary">BUTTON</a> </div> <div class="card-footer text-muted"> FOOTER </div> </div>
Card title By default, the flex-direction of the card is set to column by Bootstrap. To get the image on the left of the card(horizontal card on the small screen as well), change the flex-direction to row. Also, remove the fixed width and set the width of the image as per the content size.
To create image and text side by side use the grid system property of bootstrap and create 2 columns of span 6-6. Put your image in one column and your text in another. On smaller devices, it will automatically align vertically.
The secret sauce seem to be row + flex-row-reverse + card-img-end, for an image on the right. If you want the image on the left the sauce is row + flex-row + card-img-start.
There are a few different ways you could do this. Here's one way using the flex-row
and flex-wrap
utility classes to change the layout of elements inside the card...
https://www.codeply.com/go/l1KAQtjjbA
<div class="card flex-row flex-wrap"> <div class="card-header border-0"> <img src="//placehold.it/200" alt=""> </div> <div class="card-block px-2"> <h4 class="card-title">Title</h4> <p class="card-text">Description</p> <a href="#" class="btn btn-primary">BUTTON</a> </div> <div class="w-100"></div> <div class="card-footer w-100 text-muted"> FOOTER </div> </div>
Here's another approach using the grid...
<div class="card"> <div class="row no-gutters"> <div class="col-auto"> <img src="//placehold.it/200" class="img-fluid" alt=""> </div> <div class="col"> <div class="card-block px-2"> <h4 class="card-title">Title</h4> <p class="card-text">Description</p> <a href="#" class="btn btn-primary">BUTTON</a> </div> </div> </div> <div class="card-footer w-100 text-muted"> Footer stating cats are CUTE little animals </div> </div>
https://www.codeply.com/go/l1KAQtjjbA
I'm not sure why you have text-center
as nothing it centered in the desired example image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With