@custom-media <extension-name> [<media-query-list> | true | false ];
@custom-media --media-query-name (width < 1200px);
@custom-media --media-query-name (width < 1200px), (orientation: portrait);`@custom-media` CSS at-rule / notebook
`@custom-media` CSS at-rule
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
@custom-media --no-script not (scripting);
@media (--no-script) {
}@custom-media --medium-screen (min-width: 40em) and (max-width: 60em);
@media (--medium-screen) {
}@custom-media --screen-or-print screen, print;
@custom-media --narrow-or-tall (width < 600px) or (height > 800px);
@media (--screen-or-print) {
}
@media (--narrow-or-tall) {
}@custom-media --narrow-window (width < 32em);
@media (--narrow-window) {
}
@media (--narrow-window) and (hover) {
}
@media (--narrow-window) and (orientation: portrait) {
}/* general.css */
@custom-media --mobile-screen (width < 480px);
@custom-media --tablet-screen (width < 768px);
@custom-media --laptop-screen (width < 1024px);
@custom-media --desktop-screen (width < 1440px);
@custom-media --widescreen (width > 1441px);/* layout.css */
.container {
padding: 1rem;
}
@media (--mobile-screen) {
.container {
padding: 0.5rem;
}
}
@media (--laptop-screen) {
.container {
max-width: 1200px;
}
}
@media (--widescreen) {
.container {
max-width: 1400px;
padding: 2rem;
}
}/* typography.css */
@media (--tablet-screen) {
.container {
font-size: 0.9rem;
}
}
@media (--laptop-screen) {
.container {
font-size: 1rem;
}
}
@media (--widescreen) {
.container {
font-size: 1.1rem;
}
}@custom-media --enabled true;
@custom-media --disabled false;
@media (--enabled) {
/* These styles always apply */
body {
background-color: blue;
}
}
@media (--disabled) {
/* These styles never apply */
body {
background-color: red;
}
}@custom-media --mobile-breakpoint (width < 320px);
@media (--mobile-breakpoint) {
.container {
grid-template-columns: 2fr 1fr;
}
}
@custom-media --mobile-breakpoint (width < 480px);