I'll show you CSS3 Grid Layout, and I do, in fact, use it in those slides. Unfortunately, it is not widely supported.
Make sure your prowser supports it. For example, in Chrome you can enable it through the "experimental Web Platform features" flag in
chrome://flags
Tomek Wytrębowicz
@tomalecpl
tomalec
the only grid framework you need to know
live-coding video: youtu.be/8xQWMf0NH_sThat's the way we perceive visual information
<table>
Monthy Pyton, video from youtu.be/YgYEuJ5u1K0
position: absolute;
float: left | right;
display: table;
display: table;
Monthy Pyton, video from youtu.be/YgYEuJ5u1K0
display: flex;
#container {
display:
grid;
}
https://www.w3.org/TR/css-grid-1/
<div class="container">
<div>Logo</div>
<div>Header</div>
<div>Nav</div>
<div>Main content</div>
</div>
.container{
display: grid;
grid-template-columns: 4em 1fr;
grid-template-rows: 2em 1fr;
}
Then resize the result box.
<div class="container">
<div>A</div>
<div>B</div>
</div>
<div class="smth"></div>
.container {
display: inline-grid; /* grid */
border: 3px solid #FFC;
}
.smth{
display: inline-block;
}
<div class="container">
<div class="a">A</div>
<div class="b">B</div>
<div class="c">C</div>
<div class="d">D</div>
<div class="e">E</div>
</div>
.container{
display: grid;
grid-template-columns: minmax(150px, 1fr) 20% minmax(min-content, 2fr);/* px/em/%/.. auto, fr, minmax()*/
grid-template-rows: auto 4em;
/* direction: rtl; */
/* grid-template: 2em 1fr / 4em 1fr; */
/* grid: 2em 1fr / 4em 1fr; */
}
Then resize/shrink the result box.
<div class="container">
<div class="a">A</div>
<div class="b">B</div>
<div class="c">C</div>
<div class="d">D</div>
<div class="e">E</div>
</div>
.a{ order: 1;} /* 1 is grater than nothing */
.c{ order: 2;}
.b{ grid-column: 3;}
.c{ grid-column: 1 / span 2;}
.d{ grid-row: 1/3; /* grid lines not tracks */}
<div class="container">
<div class="a">A</div>
<div class="b">B</div>
<div class="c">C</div>
<div class="d">D</div>
<div class="e">E</div>
</div>
.container{
display: grid;
grid-template-columns: [left] 4em [center] 1fr [right prawo];
grid-template-rows: [top] 1.5em [hero] 3em [content] 1fr [bottom];
}
.a{
grid-column: left / right;
}
.b{
grid-column: center / 3;
grid-row: 2;
}
.c{
grid-row: 2 / content;
}
<div class="container">
<header>Header</header>
<nav>Nav</nav>
<div>Content</div>
<footer>Footer</footer>
</div>
.container {
display: grid;
grid: 1.5em 1fr / 5em 1fr; /* auto in 3rd row is comes as default */
grid-template-areas: "head head"
"nav main"
"foot foot";
}
.container header{
grid-area: head;
}
.container nav{
grid-area: nav;
}
.container div{
grid-area: main;
}
.container footer{
grid-area: foot;
}
Then resize the result box.
@media (max-width: 500px) {
.container {
grid-template-areas: "head"
"nav"
"subnav"
"main"
"foot";
grid-template-columns: 1fr;
grid-template-rows: 3em auto auto minmax(2em, 1fr) auto;
}
}
Then shrink the result box.
.grid {
display: grid;
grid-template-columns: repeat(12, 1fr);
/* grid-template-columns: 1fr 1fr ....; */
}
/* .grid > *{
grid-column: span 2;
}*/
Then resize the result box.
source: caniuse.com/#feat=css-grid
IE/Edge |
Prefixed with -ms |
Old spec/syntax, but quite stable |
![]() Chromium |
⚑ behind the flagexperimental-web-platform-features |
Latest spec |
Firefox |
⚑ behind the flaglayout.css.grid.enabled |
|
Webkit |
Prefixed with -webkit |
Enabled in Webkit nightlies |
Polyfill | github.com/FremyCompany/css-grid-polyfill |
Igalia's demos and examples - igalia.github.io/css-grid-layout/
Grid by example - gridbyexample.com/
Read and raport bugs in spec - w3.org/TR/css-grid-1/
Write browser tests - github.com/w3c/csswg-test
Take part in workshops - fantasai.inkedblade.net/style/events/grid-workshop
Tomek Wytrębowicz
tomalec
@tomalecpl
My other talks:
Specs:
CSS Grid Layout - w3.org/TR/css-grid-1/
CSS Flexbox Layout - w3.org/TR/css-flexbox-1/
Place to start fiddling with it
Igalia's demos and examples - igalia.github.io/css-grid-layout/
Grid by example - gridbyexample.com
Flexbox froggy - flexboxfroggy.com
CSS project:
CSS Houdini - JS meets CSS - wiki.css-houdini.org
GSS - CSS with constrain solver - gridstylesheets.org
Other:
CSS Grid workshops - fantasai.inkedblade.net/style/events/grid-workshop/
The guy who inspired me to make this talk - blogs.igalia.com/mrego/