Layout Patterns
Common layout patterns, UI patterns, and responsive techniques.
Overview
Proven layout patterns for common UI needs.
Key Concepts
- Card Layout — Content cards
- Media Object — Image with text
- Sticky Footer — Footer at bottom
- Split Screen — Two-column layout
- Featured Section — Hero with content
Code Examples
/* Card layout */
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 1.5rem;
}
.card {
background: white;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
overflow: hidden;
transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
transform: translateY(-4px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}
.card-image {
width: 100%;
aspect-ratio: 16 / 9;
object-fit: cover;
}
.card-content {
padding: 1.5rem;
}
/* Media object */
.media {
display: flex;
gap: 1rem;
align-items: flex-start;
}
.media-image {
width: 100px;
height: 100px;
border-radius: 50%;
object-fit: cover;
flex-shrink: 0;
}
.media-content {
flex: 1;
}
/* Sticky footer */
.page {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.page-content {
flex: 1;
}
/* Split screen */
.split-screen {
display: grid;
grid-template-columns: 1fr 1fr;
min-height: 100vh;
}
@media (max-width: 768px) {
.split-screen {
grid-template-columns: 1fr;
}
}
.split-left {
display: flex;
flex-direction: column;
justify-content: center;
padding: 4rem;
background: var(--primary);
color: white;
}
.split-right {
display: flex;
flex-direction: column;
justify-content: center;
padding: 4rem;
}
/* Featured section */
.featured {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 4rem;
align-items: center;
padding: 4rem;
}
.featured-image {
width: 100%;
border-radius: 8px;
}
.featured-content {
max-width: 500px;
}
/* Pricing table */
.pricing {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 2rem;
max-width: 1000px;
margin: 0 auto;
}
.pricing-card {
background: white;
border-radius: 12px;
padding: 2rem;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
text-align: center;
}
.pricing-card.featured {
border: 2px solid var(--primary);
transform: scale(1.05);
}
/* Testimonial */
.testimonial {
display: flex;
gap: 1.5rem;
align-items: flex-start;
padding: 2rem;
background: #f9f9f9;
border-radius: 8px;
}
.testimonial-avatar {
width: 60px;
height: 60px;
border-radius: 50%;
flex-shrink: 0;
}
.testimonial-content {
flex: 1;
}
.testimonial-quote {
font-style: italic;
margin-bottom: 1rem;
}
Practice
Build a landing page using multiple layout patterns.