This article will demonstrate you, how you can use bootstrap 4 cards components. A cardis a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options. if you are familiar with Bootstrap 3, cards replace old panals,well and thumbnails. Cards are build with as little markup and styles as possible, but still manage to deliver a ton of control and customazation. Card build with flexbox, they offer easy alignment and mix well with other bootstrap components.
To use Bootstrap 4 card components your project, you need to have the following downloaded or cdn link scripts,- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
Example of Basic Card
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <meta charset="utf-8" />
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container py-5">
- <div class="card">
- <div class="card-body">Basic card</div>
- </div>
- </div>
- </body>
- </html>
Output

Example of Card with header and footer
The .card-header class adds a heading to the card and the .card-footer class adds a footer to the card.
- <!DOCTYPE html>
- <html>
- <head>
- <title>Card</title>
- <meta charset="utf-8" />
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container py-5">
- <div class="card">
- <div class="card-header">
- <h5>header</h5>
- </div>
- <div class="card-body">
- <h5>bady</h5>
- </div>
- <div class="card-footer">
- <h5>footer</h5>
- </div>
- </div>
- </div>
- </body>
- </html>

Example of Card Titles, Text, and Links
Use .card-title to add card titles to any heading element. The .card-text class is used to remove bottom margins for a p element if it is the last child (or the only one) in card-body. The .card-link class adds a blue color to any link, and a hover effect.
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <meta charset="utf-8" />
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container py-5">
- <div class="card">
- <div class="card-body">
- <div class="card-title">
- Card-title
- </div>
- <div class="card-text">
- Card text
- </div>
- <a href="#" class="card-link">link-1</a>
- <a href="#" class="card-link">link-2</a>
- <a href="#" class="card-link">link-3</a>
- </div>
- </div>
- </div>
- </body>
- </html>
Output

Add .card-img-top or .card-img-bottom to an <img> to place the image at the top or at the bottom inside the card. Note that we have added the image outside of the .card-body to span the entire width.
Card Image Top
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <meta charset="utf-8" />
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container py-5">
- <h3>Bootstrap 4 Card Image</h3>
- <h4>Card image top</h4>
- <div class="card" style="width:250px;">
- <img class="card-img-top" src="images/farhan.jpg" alt="farhan" />
- <div class="card-body">
- <h4 class="card-title">Farhan Ahmed</h4>
- <p class="card-text">Hi, I am full-stack developer.</p>
- <a href="#" class="btn btn-primary rounded-0">View Profile</a>
- </div>
- </div>
- </div>
- </body>
- </html>

CaCard image bottom
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <meta charset="utf-8" />
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container py-5">
- <h3>Bootstrap 4 Card Image</h3>
- <h4>Card image bottom</h4>
- <div class="card" style="width:250px;">
- <div class="card-body">
- <h4 class="card-title">Farhan Ahmed</h4>
- <p class="card-text">Hi, I am full-stack developer.</p>
- <a href="#" class="btn btn-primary rounded-0">View Profile</a>
- </div>
- <img class="card-img-bottom" src="images/farhan.jpg" alt="farhan" />
- </div>
- </div>
- </body>
- </html>

Card image overlay turns an image into a card background and use .card-img-overlay to overlay the card's text.





JosephsPosted Sep 10, 2018, 12:09 AM
Can i use this card concept for menus in my webapplication?