Last active
January 7, 2022 10:13
-
-
Save LucaRosaldi/bac572da8d7c697e008f691aa3f730b7 to your computer and use it in GitHub Desktop.
CSS: Container Queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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