HTML Snippets

Basic structure for a custom card.

HTML
<div class="card h-100 border-0 shadow-sm" style="border-radius: 1.5rem;">
    <div class="card-body">
        <h5 class="card-title fw-bold">Card Title</h5>
        <p class="card-text text-muted">Some example text.</p>
        <a href="#" class="btn btn-gradient-pink rounded-pill">Go somewhere</a>
    </div>
</div>

CSS Styling

How we style the gradient buttons.

CSS
.btn-gradient-pink {
    background: linear-gradient(90deg, #ff6b6b, #ff8e8e);
    color: white;
    border: none;
    border-radius: 50rem;
    padding: 0.5rem 1.5rem;
    transition: all 0.3s ease;
}

.btn-gradient-pink:hover {
    background: linear-gradient(90deg, darken(#ff6b6b, 5%), darken(#ff8e8e, 5%));
    color: white;
    transform: translateY(-2px);
}

JavaScript Logic

Example of the "Go to Top" button logic.

JS
// Get the button
let mybutton = document.getElementById("goToTopBtn");

// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};

function scrollFunction() {
  if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
    mybutton.classList.remove("d-none");
  } else {
    mybutton.classList.add("d-none");
  }
}

// When the user clicks on the button, scroll to the top of the document
mybutton.addEventListener("click", function(){
    document.body.scrollTop = 0;
    document.documentElement.scrollTop = 0;
});