Carousel Card - Raccolta di codice e script

English Spanish Italian
Title
Vai ai contenuti
Carousel Card
Utilizzando solo l'oggetto HTML
(fonte CodePen)
CODICE IN OGGETTO HTML

<!-- partial:index.partial.html -->
<div id="carouselExampleControls" class="carousel slide" data-bs-ride="carousel">
 <div class="carousel-inner">
   <div class="carousel-item active">
     <div class="cards-wrapper">
       <div class="card">
         <div class="image-wrapper">
           <img src="https://codingyaar.com/wp-content/uploads/multiple-items-carousel-slide-1-card-1.jpg" alt="...">
         </div>
         <div class="card-body">
           <h5 class="card-title">Card title</h5>
           <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
             content.</p>
           <a href="#" class="btn btn-primary">Go somewhere</a>
         </div>
       </div>
       <div class="card">
         <div class="image-wrapper">
           <img src="https://codingyaar.com/wp-content/uploads/multiple-items-carousel-slide-1-card-2.jpg" alt="...">
         </div>
         <div class="card-body">
           <h5 class="card-title">Card title</h5>
           <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
             content.</p>
           <a href="#" class="btn btn-primary">Go somewhere</a>
         </div>
       </div>
       <div class="card">
         <div class="image-wrapper">
           <img src="https://codingyaar.com/wp-content/uploads/multiple-items-carousel-slide-1-card-3.jpg" alt="...">
         </div>
         <div class="card-body">
           <h5 class="card-title">Card title</h5>
           <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
             content.</p>
           <a href="#" class="btn btn-primary">Go somewhere</a>
         </div>
       </div>
     </div>
   </div>
   <div class="carousel-item">
     <div class="cards-wrapper">
       <div class="card">
         <div class="image-wrapper">
           <img src="https://codingyaar.com/wp-content/uploads/multiple-items-carousel-slide-2-card-1.jpg" alt="...">
         </div>
         <div class="card-body">
           <h5 class="card-title">Card title</h5>
           <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
             content.</p>
           <a href="#" class="btn btn-primary">Go somewhere</a>
         </div>
       </div>
       <div class="card">
         <div class="image-wrapper">
           <img src="https://codingyaar.com/wp-content/uploads/multiple-items-carousel-slide-2-card-2.jpg" alt="...">
         </div>
         <div class="card-body">
           <h5 class="card-title">Card title</h5>
           <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
             content.</p>
           <a href="#" class="btn btn-primary">Go somewhere</a>
         </div>
       </div>
       <div class="card">
         <div class="image-wrapper">
           <img src="https://codingyaar.com/wp-content/uploads/multiple-items-carousel-slide-2-card-3.jpg" alt="...">
         </div>
         <div class="card-body">
           <h5 class="card-title">Card title</h5>
           <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
             content.</p>
           <a href="#" class="btn btn-primary">Go somewhere</a>
         </div>
       </div>
     </div>
   </div>
   <div class="carousel-item">
     <div class="cards-wrapper">
       <div class="card">
         <div class="image-wrapper">
           <img src="https://codingyaar.com/wp-content/uploads/bootstrap-multiple-items-carousel-slide-3-card-1.jpg" alt="...">
         </div>
         <div class="card-body">
           <h5 class="card-title">Card title</h5>
           <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
             content.</p>
           <a href="#" class="btn btn-primary">Go somewhere</a>
         </div>
       </div>
       <div class="card">
         <div class="image-wrapper">
           <img src="https://codingyaar.com/wp-content/uploads/multiple-items-carousel-slide-3-card-2.jpg" alt="...">
         </div>
         <div class="card-body">
           <h5 class="card-title">Card title</h5>
           <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
             content.</p>
           <a href="#" class="btn btn-primary">Go somewhere</a>
         </div>
       </div>
       <div class="card">
         <div class="image-wrapper">
           <img src="https://codingyaar.com/wp-content/uploads/multiple-items-carousel-slide-3-card-3.jpg" alt="...">
         </div>
         <div class="card-body">
           <h5 class="card-title">Card title</h5>
           <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
             content.</p>
           <a href="#" class="btn btn-primary">Go somewhere</a>
         </div>
       </div>
     </div>
   </div>
 </div>
 <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="prev">
   <span class="carousel-control-prev-icon" aria-hidden="true"></span>
   <span class="visually-hidden">Previous</span>
 </button>
 <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="next">
   <span class="carousel-control-next-icon" aria-hidden="true"></span>
   <span class="visually-hidden">Next</span>
 </button>
</div>
<!-- partial -->
CODICE ESPERTO IN OGGETTO HTML (CSS)

.card {
 border: none;
 border-radius: 0;
 box-shadow: 2px 6px 8px 0 rgba(22, 22, 26, 0.18);
}
.carousel-inner {
 padding: 1em;
}
.carousel-control-prev,
.carousel-control-next {
 background-color: #e1e1e1;
 width: 6vh;
 height: 6vh;
 border-radius: 50%;
 top: 50%;
 transform: translateY(-50%);
}
.carousel-control-prev span,
.carousel-control-next span {
 width: 1.5rem;
 height: 1.5rem;
}
@media screen and (min-width: 577px) {
 .cards-wrapper {
   display: flex;
 }
 .card {
   margin: 0 0.5em;
   width: calc(100% / 2);
 }
 .image-wrapper {
   height: 20vw;
   margin: 0 auto;
 }
}
@media screen and (max-width: 576px) {
 .card:not(:first-child) {
   display: none;
 }
}

.image-wrapper img {
 max-width: 100%;
 max-height: 100%;
}
SCRIPT AGGIUNTIVI SULLA PAGINA

Dopo l'apertura del tag HEAD
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css'>

Prima della chiusura del tag BODY
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.1/js/bootstrap.min.js'></script>
Torna ai contenuti