Skip to content

Instantly share code, notes, and snippets.

@LucaRosaldi
Last active January 7, 2022 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucaRosaldi/bac572da8d7c697e008f691aa3f730b7 to your computer and use it in GitHub Desktop.
Save LucaRosaldi/bac572da8d7c697e008f691aa3f730b7 to your computer and use it in GitHub Desktop.
CSS: Container Queries
.widget-name {
container: inline-size / widget-name;
/* Shorthand for: */
/* container-type: inline-size; */
/* container-name: widget-name; */
/* For quick testing, do this to get a resize handle on desktop: */
/* resize: both; */
/* overflow: hidden; */
}
.widget-name_container {
display: flex;
}
@container widget-name size(max-width: 700px) {
.widget-name_container {
flex-direction: column;
}
}
// Support Test
const supportsContainerQueries = "container" in document.documentElement.style;
// Conditional Import
if (!supportsContainerQueries) {
import("https://cdn.skypack.dev/container-query-polyfill");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment