Tutorialspoint examples

Learn java tutorial with examples for beginners online

Bootstrap 4 Contextual Cards

Bootstrap 4 card represents a bordered box with some padding around its content. It includes options for headers, footers, content, colors, etc. Bootstrap provides the following classes to create bootstrap card.
.card: class is used to create a bootstrap card.
.card-body: class is used to add content inside the card.
.card-header: class is used to add a heading to the card.
.card-footer: class is used to add a footer to the card.

We can use contextual classes (.bg-primary, .bg-success, .bg-info, .bg-warning, .bg-danger, .bg-secondary, .bg-dark and .bg-light) to add a background color the card.

Bootstrap 4 Contextual Cards Example:

<!DOCTYPE html>
<html lang="en">
  <title>Bootstrap 4 Cards with Contextual Classes</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<div class="container">
  <h2>Bootstrap 4 Cards with Contextual Classes</h2>
  <div class="card">
    <div class="card-body">Basic card</div>
  <div class="card bg-primary text-white">
    <div class="card-body">Primary card</div>
  <div class="card bg-success text-white">
    <div class="card-body">Success card</div>
  <div class="card bg-info text-white">
    <div class="card-body">Info card</div>
  <div class="card bg-warning text-white">
    <div class="card-body">Warning card</div>
  <div class="card bg-danger text-white">
    <div class="card-body">Danger card</div>
  <div class="card bg-secondary text-white">
    <div class="card-body">Secondary card</div>
  <div class="card bg-dark text-white">
    <div class="card-body">Dark card</div>
  <div class="card bg-light text-dark">
    <div class="card-body">Light card</div>

Try it:

Bootstrap 4 Cards with Contextual Classes on jsbin.com

Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status