Bootstrap 4 - Cartões
Descrição
O cartão é um contêiner de conteúdo que exibe uma caixa delimitada com algum preenchimento ao redor. Inclui cores de fundo, cabeçalhos, rodapés e outras opções de exibição.
Cartão Básico
Para obter um cartão básico, basta adicionar a classe .card ao elemento <div> e colocar o conteúdo dentro de uma classe .card-body conforme mostrado no exemplo a seguir -
Exemplo
<html lang = "en">
<head>
<!-- Meta tags -->
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
<!-- Bootstrap CSS -->
<link rel = "stylesheet"
href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin = "anonymous">
<title>Bootstrap 4 Example</title>
</head>
<body>
<div class = "container">
<h2>Basic Card</h2>
<div class = "card">
<div class = "card-body">
<h5 class = "card-title">Tutorialspoint</h5>
<p class = "card-text">
Our mission is to deliver Simply Easy Learning with clear, crisp, and
to-the-point content on a wide range of technical and non-technical
subjects without any preconditions and impediments.
</p>
<a href="#" class = "btn btn-info">More Info</a>
</div>
</div>
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src = "https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin = "anonymous">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin = "anonymous">
</script>
<script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin = "anonymous">
</script>
</body>
</html>
Isso produzirá o seguinte resultado -
Resultado
Cabeçalho e rodapé
Você pode adicionar cabeçalho para o cartão usando a classe .card-header e rodapé usando a classe .card-footer .
O exemplo a seguir demonstra isso -
Exemplo
<html lang = "en">
<head>
<!-- Meta tags -->
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
<!-- Bootstrap CSS -->
<link rel = "stylesheet"
href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin = "anonymous">
<title>Bootstrap 4 Example</title>
</head>
<body>
<div class = "container">
<h2>Card Header and Footer</h2>
<div class = "card">
<div class = "card-header">Card Header</div>
<div class = "card-body">
<h5 class = "card-title">Tutorialspoint</h5>
<p class = "card-text">
Our mission is to deliver Simply Easy Learning with clear, crisp, and
to-the-point content on a wide range of technical and non-technical
subjects without any preconditions and impediments.
</p>
<a href = "#" class = "btn btn-info">More Info</a>
</div>
<div class = "card-footer">Card Footer</div>
</div>
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src = "https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin = "anonymous">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin = "anonymous">
</script>
<script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin = "anonymous">
</script>
</body>
</html>
Isso produzirá o seguinte resultado -
Resultado
Grupos de lista
Você pode criar uma lista de conteúdo para os cartões usando a classe .list-group-flush conforme mostrado no exemplo abaixo -
Exemplo
<html lang = "en">
<head>
<!-- Meta tags -->
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
<!-- Bootstrap CSS -->
<link rel = "stylesheet"
href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin = "anonymous">
<title>Bootstrap 4 Example</title>
</head>
<body>
<div class = "container">
<h2>List Groups</h2>
<div class = "card" style = "width: 18rem;">
<div class = "card-header">Card Header</div>
<ul class = "list-group list-group-flush">
<li class = "list-group-item">HTML-5</li>
<li class = "list-group-item">CSS-3</li>
<li class = "list-group-item">Bootstrap-4</li>
</ul>
</div>
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src = "https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin = "anonymous">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin = "anonymous">
</script>
<script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin = "anonymous">
</script>
</body>
</html>
Isso produzirá o seguinte resultado -
Resultado
Cartões Contextuais
O bootstrap usa classes contextuais como .bg-primary , .bg-success , .bg-info , .bg-warning , .bg-danger , .bg-secondary , .bg-dark e .bg-light para alterar a cor de fundo do cartão.
O exemplo a seguir demonstra isso -
Exemplo
<html lang = "en">
<head>
<!-- Meta tags -->
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
<!-- Bootstrap CSS -->
<link rel = "stylesheet"
href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin = "anonymous">
<title>Bootstrap 4 Example</title>
</head>
<body>
<div class = "container">
<h3>Contextual Cards</h3>
<div class = "card bg-primary text-white">
<div class = "card-body">Primary card</div>
</div>
<br>
<div class = "card bg-success text-white">
<div class = "card-body">Success card</div>
</div>
<br>
<div class = "card bg-info text-white">
<div class = "card-body">Info card</div>
</div>
<br>
<div class = "card bg-warning text-white">
<div class = "card-body">Warning card</div>
</div>
<br>
<div class = "card bg-danger text-white">
<div class = "card-body">Danger card</div>
</div>
<br>
<div class = "card bg-secondary text-white">
<div class = "card-body">Secondary card</div>
</div>
<br>
<div class = "card bg-dark text-white">
<div class = "card-body">Dark card</div>
</div>
<br>
<div class = "card bg-light text-dark">
<div class = "card-body">Light card</div>
</div>
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src = "https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin = "anonymous">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin = "anonymous">
</script>
<script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin = "anonymous">
</script>
</body>
</html>
Isso produzirá o seguinte resultado -
Resultado
Imagens do cartão (superior e inferior)
Você pode colocar a imagem na parte superior do cartão usando .card-img-top class ou na parte inferior usando .card-img-bottom class para o elemento <img> como mostrado no exemplo abaixo -
Exemplo
<html lang = "en">
<head>
<!-- Meta tags -->
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
<!-- Bootstrap CSS -->
<link rel = "stylesheet"
href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin = "anonymous">
<title>Bootstrap 4 Example</title>
</head>
<body>
<div class = "container">
<h2>Image at Top</h2>
<div class = "card" style = "width:350px;height:400px">
<img class = "card-img-top" src = "https://www.tutorialspoint.com/bootstrap/images/64.jpg"
alt = "Card Image Top">
<div class = "card-body">
<h4 class = "card-title">HTML</h4>
<p class = "card-text">
HTML stands for Hypertext Markup Language, and it is the most widely
used language to write Web Pages.
</p>
<a href = "#" class = "btn btn-primary">More Info</a>
</div>
</div>
<br>
<h2>Image at Bottom</h2>
<div class = "card" style = "width:350px;height:400px">
<div class = "card-body">
<h4 class = "card-title">CSS</h4>
<p class = "card-text">
Cascading Style Sheets, fondly referred to as CSS, is a simple design
language intended to simplify the process of making web pages
presentable.
</p>
<a href = "#" class = "btn btn-primary">More Info</a>
</div>
<img class = "card-img-bottom"
src = "https://www.tutorialspoint.com/bootstrap/images/64.jpg"
alt = "Card Image Bottom">
</div>
<br>
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src = "https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin = "anonymous">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin = "anonymous">
</script>
<script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin = "anonymous">
</script>
</body>
</html>
Isso produzirá o seguinte resultado -
Resultado
Sobreposição de imagem do cartão
Adicione a imagem de fundo a um cartão e coloque o texto no topo de uma imagem usando a classe .card-img-overlay .
O exemplo a seguir demonstra isso -
Exemplo
<html lang = "en">
<head>
<!-- Meta tags -->
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
<!-- Bootstrap CSS -->
<link rel = "stylesheet"
href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin = "anonymous">
<title>Bootstrap 4 Example</title>
</head>
<body>
<div class = "container">
<h2>Image Overlay</h2>
<div class = "card" style = "width:350px;height:400px">
<img class = "card-img-top"
src = "https://www.tutorialspoint.com/bootstrap/images/64.jpg"
alt = "Card image" style = "width:100%">
<div class = "card-img-overlay">
<p class = "card-text text-white">
HTML stands for Hypertext Markup Language. It is the most widely used
language to write Web Pages
</p>
<a href = "#" class = "btn btn-primary">More Info</a>
</div>
<div class = "card-body">
<h4 class = "card-title">HTML</h4>
<p class = "card-text">
HTML was developed with the intent of defining the structure of
documents like headings, paragraphs, lists, and so forth to
facilitate the sharing of scientific information between researchers.
</p>
</div>
</div>
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src = "https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin = "anonymous">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin = "anonymous">
</script>
<script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin = "anonymous">
</script>
</body>
</html>
Isso produzirá o seguinte resultado -
Resultado
Grupos de cartas
Os grupos de cartões podem ser usados para colocar vários cartões como um único elemento anexado. A classe .card-group especifica colunas de largura e altura iguais e remove as margens esquerda e direita entre cada cartão.
Note - Nas telas pequenas (menos de 576 px), os cartões serão exibidos verticalmente junto com as margens superior e inferior.
O exemplo a seguir demonstra a exibição de grupos de cartões como um único elemento anexado -
Exemplo
<html lang = "en">
<head>
<!-- Meta tags -->
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
<!-- Bootstrap CSS -->
<link rel = "stylesheet"
href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin = "anonymous">
<title>Bootstrap 4 Example</title>
</head>
<body>
<div class = "container">
<h2>Card-Groups</h2>
<div class = "card-group">
<div class = "card">
<img class = "card-img-top"
src = "https://www.tutorialspoint.com/bootstrap/images/64.jpg"
alt = "Card Groups">
<div class = "card-body">
<h5 class = "card-title">HTML</h5>
<p class = "card-text">
HTML stands for Hypertext Markup Language, and it is the most
widely used language to write Web Pages.
</p>
</div>
<div class = "card-footer">
<small class = "text-muted">Card Footer</small>
</div>
</div>
<div class = "card">
<img class = "card-img-top"
src = "https://www.tutorialspoint.com/bootstrap/images/64.jpg"
alt = "Card Groups">
<div class = "card-body">
<h5 class = "card-title">CSS</h5>
<p class = "card-text">
Cascading Style Sheets, fondly referred to as CSS, is a simple
design language intended to simplify the process of making web
pages presentable.
</p>
</div>
<div class = "card-footer">
<small class = "text-muted">Card Footer</small>
</div>
</div>
<div class = "card">
<img class = "card-img-top"
src = "https://www.tutorialspoint.com/bootstrap/images/64.jpg"
alt = "Card Groups">
<div class = "card-body">
<h5 class = "card-title">Bootstrap</h5>
<p class = "card-text">
Bootstrap is a sleek, intuitive, and powerful, mobile first
front-end framework for faster and easier web development.
</p>
</div>
<div class = "card-footer">
<small class = "text-muted">Card Footer</small>
</div>
</div>
</div>
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src = "https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin = "anonymous">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin = "anonymous">
</script>
<script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin = "anonymous">
</script>
</body>
</html>
Isso produzirá o seguinte resultado -
Resultado
Baralhos de cartas
Os baralhos de cartas especificam colunas de largura e altura iguais, que não são anexadas umas às outras. Você pode fazer isso usando a classe .card-deck .
O exemplo a seguir demonstra isso -
Exemplo
<html lang = "en">
<head>
<!-- Meta tags -->
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
<!-- Bootstrap CSS -->
<link rel = "stylesheet"
href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin = "anonymous">
<title>Bootstrap 4 Example</title>
</head>
<body>
<div class = "container">
<h2>Card Decks</h2>
<div class = "card-deck">
<div class = "card">
<img class="card-img-top"
src = "https://www.tutorialspoint.com/bootstrap/images/64.jpg"
alt = "Card Groups">
<div class = "card-body">
<h5 class = "card-title">HTML</h5>
<p class = "card-text">
HTML stands for Hypertext Markup Language, and it is the most
widely used language to write Web Pages.
</p>
</div>
<div class = "card-footer">
<small class = "text-muted">Card Footer</small>
</div>
</div>
<div class = "card">
<img class = "card-img-top"
src = "https://www.tutorialspoint.com/bootstrap/images/64.jpg"
alt = "Card Groups">
<div class = "card-body">
<h5 class = "card-title">CSS</h5>
<p class = "card-text">
Cascading Style Sheets, fondly referred to as CSS, is a simple
design language intended to simplify the process of making web
pages presentable.
</p>
</div>
<div class = "card-footer">
<small class = "text-muted">Card Footer</small>
</div>
</div>
<div class = "card">
<img class = "card-img-top"
src = "https://www.tutorialspoint.com/bootstrap/images/64.jpg"
alt = "Card Groups">
<div class = "card-body">
<h5 class = "card-title">Bootstrap</h5>
<p class = "card-text">
Bootstrap is a sleek, intuitive, and powerful, mobile first
front-end framework for faster and easier web development.
</p>
</div>
<div class = "card-footer">
<small class = "text-muted">Card Footer</small>
</div>
</div>
</div>
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src = "https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin = "anonymous">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin = "anonymous">
</script>
<script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin = "anonymous">
</script>
</body>
</html>
Isso produzirá o seguinte resultado -
Resultado
Colunas de cartas
Os cartões podem ser colocados em uma estrutura de layout de grade usando a classe .card-columns, conforme mostrado no exemplo abaixo -
Exemplo
<html lang = "en">
<head>
<!-- Meta tags -->
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
<!-- Bootstrap CSS -->
<link rel = "stylesheet"
href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin = "anonymous">
<title>Bootstrap 4 Example</title>
</head>
<body>
<div class = "container">
<h2>Card Columns</h2>
<div class =" card-columns">
<!-- Card 1 -->
<div class = "card">
<div class = "card-header">Card Header</div>
<div class = "card-body">
<p class = "card-text">This is Card - 1</p>
</div>
</div>
<!-- Card 2 -->
<div class = "card">
<div class = "card-body">
<p class = "card-text">This is Card - 2</p>
</div>
</div>
<!-- Card 3 -->
<div class = "card">
<div class = "card-header">Card Header</div>
<div class = "card-body">
<p class = "card-text">
This is Card - 3 with
<a href = "#" class = "card-link">link</a>
</p>
</div>
<div class = "card-footer">Card Footer</div>
</div>
<!-- Card 4 -->
<div class = "card">
<div class = "card-header">Card Header</div>
<div class = "card-body">
<p class = "card-text">This is Card - 4</p>
</div>
<div class = "card-footer">Card Footer</div>
</div>
<!-- Card 5 -->
<div class = "card">
<div class = "card-body">
<h4 class = "card-title">Card Title</h4>
<p class = "card-text">This is Card - 5</p>
</div>
</div>
<!-- Card 6 -->
<div class = "card">
<div class = "card-header">Card Header</div>
<div class = "card-body">
<p class = "card-text">
This is Card - 6 with <a href = "#" class = "card-link">link</a>
</p>
</div>
</div>
<!-- Card 7 -->
<div class = "card">
<div class = "card-header">Card Header</div>
<div class = "card-body">
<p class = "card-text">This is Card - 7</p>
</div>
<div class = "card-footer">Card Footer</div>
</div>
<!-- Card 8 -->
<div class = "card text-white" >
<!-- Image -->
<img class = "card-img"
src = "https://www.tutorialspoint.com/bootstrap/images/64.jpg"
alt = "Photo of Cat">
<!-- Text Content -->
<div class = "card-img-overlay">
<h4 class = "card-title">Card 8</h4>
<p class = "card-text">This is an image for Card - 8</p>
</div>
</div>
</div>
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src = "https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin = "anonymous">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin = "anonymous">
</script>
<script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin = "anonymous">
</script>
</body>
</html>
Isso produzirá o seguinte resultado -
Resultado
Navegação
Você pode criar nav tab ou nav pill ao cartão adicionando a classe .card-header-tabs ou a classe .card-header-pills ao elemento <ul>.
O exemplo a seguir demonstra a adição de nav tab e nav pill ao cartão -
Exemplo
<html lang = "en">
<head>
<!-- Meta tags -->
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
<!-- Bootstrap CSS -->
<link rel = "stylesheet"
href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin = "anonymous">
<title>Bootstrap 4 Example</title>
</head>
<body>
<div class = "container">
<h2>Navigation Tab</h2>
<div class = "card text-center">
<div class = "card-header">
<ul class = "nav nav-tabs card-header-tabs">
<li class = "nav-item">
<a class = "nav-link active" href = "#">HTML</a>
</li>
<li class = "nav-item">
<a class = "nav-link" href = "#">CSS</a>
</li>
<li class = "nav-item">
<a class = "nav-link " href = "#">Bootstrap</a>
</li>
</ul>
</div>
<div class = "card-body">
<h5 class = "card-title">Title</h5>
<p class = "card-text">Content goes here...</p>
</div>
</div>
<br>
<h2>Navigation Pill</h2>
<div class = "card text-center">
<div class = "card-header">
<ul class = "nav nav-pills card-header-pills">
<li class = "nav-item">
<a class = "nav-link active" href = "#">HTML</a>
</li>
<li class = "nav-item">
<a class = "nav-link" href = "#">CSS</a>
</li>
<li class = "nav-item">
<a class = "nav-link " href = "#">Bootstrap</a>
</li>
</ul>
</div>
<div class = "card-body">
<h5 class = "card-title">Title</h5>
<p class = "card-text">Content goes here...</p>
</div>
</div>
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src = "https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin = "anonymous">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin = "anonymous">
</script>
<script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin = "anonymous">
</script>
</body>
</html>
Isso produzirá o seguinte resultado -