As presented at dotCSS in Paris, France
Responsive WebApplicationswith Container Queries
View Slide
Why We NeedContainer Queries
• No orders• One order• Less than one page oforders• Multiple pages oforders• Has Info Notifications• Tab overflow• Has WarningNotifications• Has limited access tofeatures• Has different appsinstalled
And now consider all ofthose things formultiple viewports
With media queries,you have to know theinterplay of all objectsin all scenarios
ImplementingContainer Queries
With containerqueries, you only haveto know the interplaywithin a single object
No containerqueries!
Declare in:CSS,HTML, or JavaScript
https://github.com/ResponsiveImagesCG/cq-demos.element:media( min-width:500px ) {}https://github.com/tysonmatanich/elementQuery.element[min-width~="500px"] {background-color: #eee;}
http://elementqueries.com/@element ".element" and (min-width: 500px) {.element {background: gold;}}
https://github.com/tysonmatanich/elementQuery.element[min-width~="400px"] { }
To parse CSS, eitherneed to be on samedomain or set up CORS
https://github.com/Snugug/eq.jsdata-eq-pts="small: 400, medium: 600,large: 900"
At HTML level, requiresconsistency ofimplementation across app
We chose JavaScriptand built our own
elements = [{"module": ".flex--2x1","className":"responsiveClass","minWidth": 768, "maxWidth": 1024}]
Why is this so f**kin’ hard?
.element:media( min-width:500px ) {width: 400px;}
.element {width: 50%;}.element:media( min-width:500px ) {color: blue;}
The Future
ResizeObserver
Houdini
What’s Houdini:• Layout API• Custom Paint API• Parser API• Properties and Values• Animation Workout• Typed OM• Font Metrics API
In Chrome:• Layout API• Custom Paint API• Parser API• Properties and Values• Animation Worklet• Typed OM• Font Metrics API
… …
.two-columns {display: flex;flex-wrap: wrap;}.col1, .col2 { flex-grow: 1; }.col1 {flex-basis: 66%;min-width: 360px;}.col2 {flex-basis: 33%;}
Button
.media-body {display: flex;flex-wrap: wrap;}
.media-content {flex-grow: 1;flex-basis: 400px;margin-right: 20px;}
.media-actions {align-self: center;margin: 20px 0;}
...
.box {display: flex;flex-wrap: wrap;}
.box-image {flex-grow: 1;flex-shrink: 0;flex-basis: 150px;}.box-image > img {width: 100%;object-fit: cover;}
.box-content {margin: 10px;flex-shrink: 1;flex-grow: 1;flex-basis: 60%;}
………
.items {display: grid;grid-template-columns:repeat(auto-fit, minmax(400px, 1fr));}
Thank you. http://snook.ca/ @snookca