Toggle navigation
☰
Home
HTML
CSS
Scripting
Database
<!DOCTYPE html> <title>My Example</title> <!-- Place the following CSS in your <head> or stylesheet --> <style> /* This is an optional body style to provide a background for the page */ body { background-color: #f9fafb; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; } /* === Grid Container for the Cards === */ .cards-grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem; padding: 1.5rem; /* Provides spacing from the viewport edges */ } /* === Badge Card Styles === */ .badge-card { --badge-card-radius: 12px; --badge-card-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1); background: #ffffff; border-radius: var(--badge-card-radius); overflow: hidden; /* Important for containing the image within rounded corners */ box-shadow: var(--badge-card-shadow); position: relative; /* This is the positioning context for the badge */ transition: transform 0.2s ease-in-out; } .badge-card:hover { transform: translateY(-5px); } .badge-card-link { text-decoration: none; color: inherit; display: block; } /* === The Badge Element === */ .badge-card-badge { position: absolute; top: 1rem; right: 1rem; padding: 0.25rem 0.75rem; border-radius: 9999px; /* Pill shape */ font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; z-index: 10; } /* Badge Color Variations */ .badge-new { background-color: #1d4ed8; /* Strong Blue */ color: #ffffff; } .badge-featured { background-color: #f59e0b; /* Amber */ color: #000000; } .badge-sale { background-color: #dc2626; /* Red */ color: #ffffff; } /* === Card Content === */ .badge-card-image { width: 100%; height: 220px; object-fit: cover; display: block; } .badge-card-content { padding: 1.5rem; } .badge-card-title { font-size: 1.25rem; font-weight: 600; line-height: 1.3; margin-top: 0; margin-bottom: 0.5rem; } .badge-card-description { font-size: 1rem; line-height: 1.5; margin: 0; color: #4b5563; } </style> <!-- Place the following HTML in your <body> --> <div class="cards-grid-container"> <!-- Card 1 --> <article class="badge-card"> <a href="#" class="badge-card-link"> <div class="badge-card-badge badge-new">New</div> <!-- Image by Unsplash. Replace with your own. --> <img class="badge-card-image" src="https://images.unsplash.com/photo-1542291026-7eec264c27ff?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80" alt="A modern red and white athletic shoe on a plain background."> <div class="badge-card-content"> <h3 class="badge-card-title">AeroStride Runners</h3> <p class="badge-card-description">Our latest model, engineered for maximum comfort and performance on any terrain.</p> </div> </a> </article> <!-- Card 2 --> <article class="badge-card"> <a href="#" class="badge-card-link"> <div class="badge-card-badge badge-featured">Featured</div> <!-- Image by Unsplash. Replace with your own. --> <img class="badge-card-image" src="https://images.unsplash.com/photo-1523275335684-37898b6baf30?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80" alt="A classic silver wristwatch with a white face and detailed dials."> <div class="badge-card-content"> <h3 class="badge-card-title">Chrono-Classic Watch</h3> <p class="badge-card-description">Timeless design meets modern precision. A perfect accessory for any occasion.</p> </div> </a> </article> <!-- Card 3 --> <article class="badge-card"> <a href="#" class="badge-card-link"> <div class="badge-card-badge badge-sale">Sale</div> <!-- Image by Unsplash. Replace with your own. --> <img class="badge-card-image" src="https://images.unsplash.com/photo-1572635196237-14b3f281503f?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80" alt="A pair of black-framed sunglasses resting on a reflective surface."> <div class="badge-card-content"> <h3 class="badge-card-title">Nova Sunglasses</h3> <p class="badge-card-description">Classic style with modern UV protection. Get them now at a discounted price.</p> </div> </a> </article> </div>