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(280px, 1fr)); gap: 1.5rem; padding: 1.5rem; } /* === Product Card (base styles are the same) === */ .oos-card { --oos-card-radius: 12px; --oos-card-shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.07); background-color: #ffffff; border-radius: var(--oos-card-radius); box-shadow: var(--oos-card-shadow); overflow: hidden; display: flex; flex-direction: column; } /* Link container for image and title */ .oos-card-link { text-decoration: none; color: inherit; display: block; } /* Image container styling */ .oos-card-image-container { position: relative; background-color: #f3f4f6; } .oos-card-image { width: 100%; height: 300px; object-fit: cover; display: block; } /* Content block styling */ .oos-card-content { padding: 1rem 1.25rem; display: flex; flex-direction: column; flex-grow: 1; /* Pushes footer to the bottom */ } .oos-card-category { font-size: 0.8rem; color: #6b7280; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; } .oos-card-title { font-size: 1.1rem; font-weight: 600; line-height: 1.4; margin: 0; } /* Footer with price and CTA */ .oos-card-footer { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-top: 1px solid #f3f4f6; margin-top: 1rem; } .oos-card-price { font-size: 1.2rem; font-weight: 700; color: #111827; } /* === OUT OF STOCK MODIFIERS === */ /* Add the 'is-out-of-stock' class to the main .oos-card element */ .oos-card.is-out-of-stock { background-color: #f9fafb; /* Slightly muted background */ cursor: not-allowed; } .oos-card.is-out-of-stock .oos-card-link { pointer-events: none; /* Disables click on the main link */ } /* Grayscale the image */ .oos-card.is-out-of-stock .oos-card-image { filter: grayscale(100%); } /* Out of Stock Overlay */ .oos-card.is-out-of-stock .oos-card-image-container::after { content: 'Out of Stock'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background-color: rgba(255, 255, 255, 0.7); font-size: 2rem; font-weight: 600; color: #374151; z-index: 1; } /* Disabled button state */ .oos-card.is-out-of-stock .oos-cta { background-color: #d1d5db; /* Gray background */ color: #6b7280; cursor: not-allowed; } .oos-card.is-out-of-stock .oos-cta:hover { background-color: #d1d5db; } </style> <!-- Place the following HTML in your <body> --> <div class="cards-grid-container"> <!-- Add the .is-out-of-stock class to the article tag to apply the styles --> <article class="oos-card is-out-of-stock"> <a href="#" class="oos-card-link" tabindex="-1"> <div class="oos-card-image-container"> <!-- Image by placehold.co. Replace with your own. --> <img src="https://placehold.co/600x600/ef4444/ffffff/png?text=Jacket" alt="A red waterproof jacket." class="oos-card-image"> </div> <div class="oos-card-content"> <span class="oos-card-category">Apparel</span> <h3 class="oos-card-title">Explorer Tech Jacket</h3> </div> </a> <footer class="oos-card-footer"> <span class="oos-card-price">$199.99</span> <button type="button" class="oos-cta" disabled>Out of Stock</button> </footer> </article> <!-- A regular in-stock card for comparison --> <article class="oos-card"> <a href="#" class="oos-card-link"> <div class="oos-card-image-container"> <!-- Image by placehold.co. Replace with your own. --> <img src="https://placehold.co/600x600/3b82f6/ffffff/png?text=Backpack" alt="A blue travel backpack." class="oos-card-image"> </div> <div class="oos-card-content"> <span class="oos-card-category">Bags</span> <h3 class="oos-card-title">Nomad Travel Backpack</h3> </div> </a> <footer class="oos-card-footer"> <span class="oos-card-price">$120.00</span> <button type="button" class="oos-cta">Add to Cart</button> </footer> </article> </div>