🌞

Card Components

The building blocks of modern UI - versatile, reusable, and beautiful

Basic Card Patterns

Essential card designs that form the foundation of any modern interface.

Simple Card

Card Title

This is a simple card with basic styling. Perfect for displaying content in a clean, organised way.

Learn more →
/* Basic card */
.card {
    background: var(--colour-surface);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.card-text {
    color: var(--colour-text-secondary);
    line-height: 1.6;
}

Image Card

Beautiful Landscape

Cards with images draw attention and provide visual context for your content.

Jan 15, 2024 Nature
/* Image card */
.card-image {
    overflow: hidden;
}

.card-image-top {
    height: 200px;
    background: linear-gradient(45deg, #3b82f6, #8b5cf6);
    margin: -1.5rem -1.5rem 1.5rem;
}

.card-body {
    padding: 0 1.5rem 1.5rem;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--colour-text-secondary);
}

Profile Card

Jane Smith

Senior Designer

Passionate about creating beautiful, user-friendly interfaces that delight users.

127 Projects
4.9 Rating
52 Awards
/* Profile card */
.card-profile {
    text-align: center;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    margin: 0 auto 1rem;
}

.profile-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--colour-border);
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--colour-primary);
}

Advanced Card Designs

More complex card patterns with rich interactions and visual effects.

Product Card

Sale

Premium Headphones

Wireless noise-cancelling headphones with premium sound quality.

★★★★★ (128 reviews)
£249 £299
/* Product card */
.card-product {
    position: relative;
    transition: transform 0.3s ease;
}

.card-product:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.product-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--colour-error);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.product-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.stars {
    color: #f59e0b;
}

Feature Card

🚀

Lightning Fast

Optimised for speed with lazy loading and efficient caching strategies.

  • Sub-second load times
  • CDN integration
  • Smart caching
Learn about performance
/* Feature card */
.card-feature {
    border: 2px solid transparent;
    background: linear-gradient(var(--colour-surface), var(--colour-surface)) padding-box,
                linear-gradient(135deg, #667eea, #764ba2) border-box;
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.feature-list li::before {
    content: "✓";
    color: var(--colour-success);
    font-weight: bold;
    margin-right: 0.5rem;
}

Testimonial Card

"

This CSS showcase has been an invaluable resource for our team. The examples are practical and the code is clean and well-documented.

Alex Johnson

Lead Developer, TechCorp

/* Testimonial card */
.card-testimonial {
    position: relative;
    background: var(--colour-surface-variant);
}

.quote-icon {
    font-size: 4rem;
    line-height: 1;
    color: var(--colour-primary);
    opacity: 0.2;
}

.testimonial-text {
    font-style: italic;
    line-height: 1.8;
    margin: 1rem 0 1.5rem;
}

.testimonial-author {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.author-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f06, #48f);
}

Card Layouts

Different ways to arrange and display cards for various use cases.

Grid Layout

Card 1
Card 2
Card 3
Card 4
Card 5
Card 6
/* Responsive grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

Masonry Layout

Tall Card
Regular
Short
Regular
Tall Card
Short
/* Masonry with columns */
.cards-masonry {
    columns: 3;
    column-gap: 1.5rem;
}

.card-masonry {
    break-inside: avoid;
    margin-bottom: 1.5rem;
}

Horizontal Scroll

Card 1
Card 2
Card 3
Card 4
Card 5
/* Horizontal scroll */
.cards-scroll {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.card-scroll {
    flex: 0 0 300px;
    scroll-snap-align: start;
}

Interactive Cards

Cards with engaging hover effects, animations, and interactive elements.

Flip Card

Front Side

Hover to see the back

Back Side

Hidden information revealed!

/* 3D flip card */
.card-flip-container {
    perspective: 1000px;
}

.card-flip {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.card-flip-container:hover .card-flip {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    backface-visibility: hidden;
}

.card-back {
    transform: rotateY(180deg);
}

Expanding Card

Click to Expand

This card contains more information...

Here's the additional content that was hidden. You can include detailed information, images, or any other content that appears on interaction.

/* Expanding card */
.card-expand {
    cursor: pointer;
}

.expand-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.card-expand.expanded .expand-content {
    max-height: 200px;
}

.expand-toggle {
    background: none;
    border: none;
    color: var(--colour-primary);
    cursor: pointer;
    font-weight: 600;
}

Hover Reveal

Hidden Details

This overlay appears on hover with additional information and actions.

/* Hover reveal overlay */
.card-hover-reveal {
    position: relative;
    overflow: hidden;
}

.reveal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card-hover-reveal:hover .reveal-overlay {
    opacity: 1;
}

Card Design Best Practices

📐

Consistent Spacing

Use a spacing system to maintain consistent padding and margins across all cards.

Accessible Actions

Ensure interactive elements have proper focus states and are keyboard navigable.

📱

Responsive Design

Cards should stack vertically on mobile and adapt to different screen sizes.

🎨

Visual Hierarchy

Use typography, colour, and spacing to guide users through card content.

You've Mastered CSS!

Congratulations on completing the CSS Showcase. Keep experimenting and building amazing things!