On this page
Media & Container Queries
Prev: at_rules | Up: at_rules | Next: Layers, Scope & Custom Properties
Rel: Responsive Design & Theming, Display & Layout
Ref: MDN Web Docs — CSS Container Queries
Tags: #public #web #css #at-rules #responsive
Contents
- > `@media` (Viewport & User Preferences)
- > `@container` (Component-Level Responsiveness)
- > `@supports` (Feature Queries)
@media (Viewport & User Preferences)
Modern range syntax replaces min-width/max-width with clean comparisons:
@media (width >= 48rem) {
.layout { grid-template-columns: 16rem 1fr; }
}
@media (prefers-color-scheme: dark) {
:root { color-scheme: dark; }
}
@container (Component-Level Responsiveness)
Container queries adapt a component to its parent container's size rather than the global viewport:
.card-wrapper {
container-type: inline-size;
container-name: card;
}
@container card (width >= 28rem) {
.card {
display: grid;
grid-template-columns: 10rem 1fr;
}
}
@supports (Feature Queries)
@supports (display: subgrid) {
.card-grid { grid-template-rows: subgrid; }
}
Linked from
Related notes
- tuts/css/tutorials/responsive_design_and_theming Linked here; links to this page; shared tags: #css, #responsive, #web
- tuts/css/at_rules Linked here; links to this page; shared tags: #css, #web
- tuts/css/at_rules/layers_and_scope Linked here; links to this page; shared tags: #css, #web
- tuts/css/properties/display_and_layout Linked here; shared tags: #css, #web
- tuts/css shared tags: #css, #web
- tuts/css/at_rules/keyframes_and_fonts shared tags: #css, #web
- tuts/css/functions shared tags: #css, #web
- tuts/css/functions/color shared tags: #css, #web
- tuts/css/functions/color/color-mix shared tags: #css, #web
- tuts/css/functions/color/light-dark shared tags: #css, #web