← Back to Menu

Media Queries

Learn how CSS conditionally applies styles based on viewport size, orientation, color-scheme preference, and more.

1. Viewport Playground

Drag the right edge of the preview to resize it. Watch breakpoints fire and the layout adapt in real-time.

Mobile < 480px
Tablet 480 – 768px
Desktop 768 – 1024px
Wide > 1024px
↔ 800px
🎨

Design

Beautiful interfaces crafted with care and precision.

Develop

Fast, modern code built for performance and scale.

🚀

Deploy

Ship with confidence using automated pipelines.

Active CSS Rules

/* Base styles (no media query) */
.pg-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

2. Breakpoint Builder

Craft your own media query and see it apply to a live preview.

Build a Rule


Generated CSS

@media (min-width: 600px) {
  .target {
    background-color: #f2ba49;
  }
}

Live Preview

Resize browser to test

3. Common Patterns

Pre-built responsive patterns. Click each tab to see the code and watch the playground react.

CSS

↔ 800px

4. Media Features Cheatsheet

A quick reference of the most useful media features available in CSS.

Range

min-width / max-width

@media (min-width: 768px) { … }

Targets viewports at or above/below a specific width. The most commonly used media feature.

Range

min-height / max-height

@media (min-height: 600px) { … }

Targets viewports at or above/below a specific height. Useful for landscape layouts.

Discrete

orientation

@media (orientation: portrait) { … }

Matches when height ≥ width (portrait) or width > height (landscape).

Discrete

prefers-color-scheme

@media (prefers-color-scheme: dark) { … }

Detects if the user has requested a light or dark color theme at the OS level.

Discrete

prefers-reduced-motion

@media (prefers-reduced-motion: reduce) { … }

Detects if the user prefers minimal animations. Essential for accessibility.

Discrete

hover

@media (hover: hover) { … }

Detects if the primary input mechanism can hover over elements. False on touchscreens.

Range

aspect-ratio

@media (min-aspect-ratio: 16/9) { … }

Targets viewports with a specific aspect ratio. Great for cinematic layouts.

Discrete

pointer

@media (pointer: coarse) { … }

Detects input precision — coarse for touch, fine for mouse. Adjust tap targets accordingly.