Bootstrap 4 - Cartas
Descripción
La tarjeta es un contenedor de contenido que muestra una caja bordeada con algo de relleno alrededor. Incluye colores de fondo, encabezados, pies de página y otras opciones de visualización.
Tarjeta básica
Para obtener una tarjeta básica, simplemente agregue la clase .card al elemento <div> y coloque el contenido dentro de una clase .card-body como se muestra en el siguiente ejemplo:
Ejemplo
<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>
Producirá el siguiente resultado:
Salida
Encabezado y pié de página
Puede agregar encabezado para la tarjeta usando la clase .card-header y pie de página usando la clase .card-footer .
El siguiente ejemplo demuestra esto:
Ejemplo
<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>
Producirá el siguiente resultado:
Salida
Lista de grupos
Puede crear una lista de contenido para las tarjetas utilizando la clase .list-group-flush como se muestra en el siguiente ejemplo:
Ejemplo
<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>
Producirá el siguiente resultado:
Salida
Tarjetas contextuales
Bootstrap utiliza clases contextuales como .bg-primary , .bg-success , .bg-info , .bg-warning , .bg-danger , .bg-secondary , .bg-dark y .bg-light para cambiar el color de fondo de la tarjeta.
El siguiente ejemplo demuestra esto:
Ejemplo
<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>
Producirá el siguiente resultado:
Salida
Imágenes de tarjetas (superior e inferior)
Puede colocar la imagen en la parte superior de la tarjeta usando la clase .card-img-top o en la parte inferior usando la clase .card-img-bottom para el elemento <img> como se muestra en el siguiente ejemplo:
Ejemplo
<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>
Producirá el siguiente resultado:
Salida
Superposición de imagen de tarjeta
Agregue la imagen de fondo a una tarjeta y coloque el texto en la parte superior de una imagen usando la clase .card-img-overlay .
El siguiente ejemplo demuestra esto:
Ejemplo
<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>
Producirá el siguiente resultado:
Salida
Grupos de cartas
Los grupos de tarjetas se pueden utilizar para colocar varias tarjetas como un solo elemento adjunto. La clase .card-group especifica columnas de igual ancho y alto y elimina los márgenes izquierdo y derecho entre cada tarjeta.
Note - En las pantallas pequeñas (menos de 576 px), las tarjetas se mostrarán verticalmente junto con los márgenes superior e inferior.
El siguiente ejemplo demuestra la visualización de grupos de tarjetas como un solo elemento adjunto:
Ejemplo
<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>
Producirá el siguiente resultado:
Salida
Barajas de cartas
Los mazos de cartas especifican columnas de igual ancho y alto que no están unidas entre sí. Puede hacer esto usando la clase .card-deck .
El siguiente ejemplo demuestra esto:
Ejemplo
<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>
Producirá el siguiente resultado:
Salida
Columnas de tarjetas
Las tarjetas se pueden colocar en la estructura de diseño de cuadrícula utilizando la clase .card-columnas como se muestra en el siguiente ejemplo
Ejemplo
<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>
Producirá el siguiente resultado:
Salida
Navegación
Puede crear una pestaña de navegación o una píldora de navegación en la tarjeta agregando la clase .card-header-tabs o la clase .card-header-pills al elemento <ul>.
El siguiente ejemplo demuestra la adición de la pestaña de navegación y la píldora de navegación a la tarjeta:
Ejemplo
<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>
Producirá el siguiente resultado: