By Florian Rivoal
@frivoal
Slides at florian.rivoal.net/talks/mq4/
@media screen { a { color: cyan; text-decoration: underline; } } @media print { a::after { content: " (" attr(href) ")"; } }
@media (min-width: 20em) { blockquote { float: left; margin-top: 0; margin-left: 0; } }
Only a few are useful in practice
@media screen and (orientation: portrait), print { @media (min-width: 20em) and (max-width: 40em) { … } }
@media (min-width: 20em) and (max-width: 40em) { … }
@media (20em <= width <= 40em) { … }
@media (min-width: 20em), (min-height: 40em) { @media not all and (pointer: none) { … } }
@media ((min-width: 20em) or (min-height: 40em)) and (not (pointer: none)) { … }
@media not (foo: none) { /* or 0, or falsy value */ … }
@media (foo) { … }
@media (min-width: 20em), not all and (min-height: 40em) { @media not all and (pointer: none) { … } }
@media ((width >= 20em) or (height < 40em)) and (pointer) { … }
@media (width > 1px) or (weight < 40kg) { … }
@media (width > 9000px) and (taste: sweet) { … }
unknown or true = true unknown and false = false unknown and true = unknown unknown or false = unknown not unknown = unknown @media unknown = @media false
Must match exactly 1 of these:
📵 😢
Make inherently robust sites using Flexbox, grid, Multicol, vh & vw, min-width & max-width… Demo by Jen Simmons
@media (width: 320px) { /* iPhone design */ }
@media (width: 320px), (width: 375px) { /* iPhone design */ }
@media (width: 320px), (width: 375px), (width: 414px) { /* iPhone design */ }
@media (width < 20em) { /* narrow design*/ }
px
@media (width > 640px) { /* wide design */ }
em
@media (width > 40em) { /* wide design*/ }
@media (pointer: coarse) or (pointer: fine) { … }
@media (pointer) { … }
@media (width: 320px) { /* big touch targets because iPhone */ }
@media (pointer: coarse) { /* big touch targets */ }
/* Complex design */ @media (/* Detect limiting media */) { /* Turn off fancy features, insert fallback */ }
/* Simple design */ @media (/* Detect capable media */) { /* Turn on fancy feature */ } @media (/* Detect other capability */) { /* Other fancy feature */ }
florian.rivoal.net/talks/mq4/