Slide 1

Slide 1 text

EMBRACE THE VERTICAL The Future of Height-Based Media Queries ANTOINE BUTLER Front End Developer, HZDG @aebsr / aeb.sr

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

EMBRACE THE VERTICAL The Future of Height-Based Media Queries

Slide 4

Slide 4 text

“ “What do you want to know about vertical media queries?”

Slide 5

Slide 5 text

WHAT’S A VERTICAL MEDIA QUERY? UH…

Slide 6

Slide 6 text

Good question.

Slide 7

Slide 7 text

But first, what’s a media query?

Slide 8

Slide 8 text

A media query allows you to tailor your layout based on any number of conditions against a media type.

Slide 9

Slide 9 text

AVAILABLE CONDITIONS Aspect ratio, Orientation, Resolution, Color and Size Aspect Ratio Orientation Resolution Color Size

Slide 10

Slide 10 text

LET’S TALK
 ABOUT SIZE. It’s not just the width that ma ers.

Slide 11

Slide 11 text

“ – Chris Coyier “Measuring width is a nice practical example of media queries, but it isn't the only thing available.” css-tricks.com/css-media-queries/

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

@media (max-width: 600px)

Slide 14

Slide 14 text

@media (max-height: 600px)

Slide 15

Slide 15 text

So What?

Slide 16

Slide 16 text

1. Content size is variable not intrinsic.

Slide 17

Slide 17 text

2. Increases scrolling.

Slide 18

Slide 18 text

3. Device* fragmentation

Slide 19

Slide 19 text

NETBOOKS AND APPLES AND ANDROIDS, OH MY!

Slide 20

Slide 20 text

REMEMBER THIS? http://opensignal.com/reports/fragmentation-2013/

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

BETTER?

Slide 23

Slide 23 text

BEST?

Slide 24

Slide 24 text

4. Squishy isn’t good enough.

Slide 25

Slide 25 text

IT’S A DODGEBALL… UNLESS

Slide 26

Slide 26 text

“ “Squishy is a legacy solution, but it is the foundation of responsive web design.” – Me

Slide 27

Slide 27 text

FLUID CIRCA 1999

Slide 28

Slide 28 text

AND THAT’S HOW WE GOT HERE.

Slide 29

Slide 29 text

So, what do we do?

Slide 30

Slide 30 text

ADAPT Or die trying.

Slide 31

Slide 31 text

“ “Smart organizations will see this as a benefit, not a drawback, and will use this chance to make a be er website, not just a squishy one.” – Karen McGrane http://alistapart.com/column/responsive-design-wont-fix-your-content-problem

Slide 32

Slide 32 text

So, what are vertical media queries again?

Slide 33

Slide 33 text

An adaptive solution.

Slide 34

Slide 34 text

MEAT & POTATOES HTML & CSS

Slide 35

Slide 35 text

Wikipedia.com Long Form Reading

Slide 36

Slide 36 text

Users of supported mobile devices are automatically redirected to the official mobile version of Wikipedia. http://en.wikipedia.org/wiki/Help:Mobile_access

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

MOBILE VS DESKTOP Accordion Layout Center Images Serif Font Simplified Navigation

Slide 39

Slide 39 text

Article Title

Introductory text...

Section Title

Lorem ipsum dolor....

Slide 40

Slide 40 text

Article Title

<figure>

Introductory text...

Section Title

Lorem ipsum dolor....

Slide 41

Slide 41 text

bit.ly/WikiProto

Slide 42

Slide 42 text

article { font: 300 1em/1.6 sans-serif; } ! article h2 { border-bo om: 1px solid #000; } ! article figure { float: right; text-align: center; }

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

/* roughly 650px to target small screens */ ! @media screen and (max-width: 40em) { figure { width: 100%; } } ! @media screen and (max-height: 40em) { article { font-family: serif; } ! article section { display: none; } }

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

BENEFITS OF AN ADAPTIVE WIKIPEDIA.COM No Device Detection Single Code Base SEO & Sharability

Slide 47

Slide 47 text

vw.com Sticky ‘Vertical’ Nav

Slide 48

Slide 48 text

New requirements.

Slide 49

Slide 49 text

1. Primary navigation must support up to 6 items.

Slide 50

Slide 50 text

2. Secondary navigation must support an unlimited
 number of items.

Slide 51

Slide 51 text

3. Keyboard accessible

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

bit.ly/StickyNav

Slide 54

Slide 54 text

Slide 55

Slide 55 text

@theme: #C2D6EB; @nav-font-size: 0.6875em; // 11px @nav-size: 8.636363636em; // 95px @logo-height: 10.454545455em; // 115px @drawer-width: 21.363636364em; // 235px @highlight-num: 6; @min-num: 3;

Slide 56

Slide 56 text

nav { transition: all 0.15s; transform: translateX(-@drawer-width); position: fixed; background: #fff; width: unit(@nav-size + @drawer-width, em); top: 0; bo om: 0; text-transform: uppercase; font-weight: bold; font-size: @nav-font-size; le er-spacing: -0.036363636em; }

Slide 57

Slide 57 text

a { padding: 1.5em; border-bo om: 0; font-weight: normal; display: block; color: #666; transition: all 0.15s; text-decoration: none; img, span { margin-le : 0.5em; margin-right: 0.5em; display: inline-block; vertical-align: middle; } }

Slide 58

Slide 58 text

ul { width: @drawer-width; overflow: scroll; &:a er { content: ''; width: 1px; height: 100%; position: fixed; background: lighten(@theme, 10%); top: 0; right: @nav-size; } }

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

! // -------------------------------------------------------- // Calculate offsets, account for first link being the logo // -------------------------------------------------------- @offset: @highlight-num + 1; @min-offset: @min-num + 1;

Slide 61

Slide 61 text

.highlight(@height: @nav-size) { display: table; position: absolute; right: 0; a { display: table-cell; border-bo om: 1px solid lighten(@theme, 10%); color: darken(@theme, 40%); height: @height; width: @nav-size; padding: 0.75rem; text-align: center; vertical-align: middle; img { margin: 0 auto; display: block; width: auto; } span { margin: 0.5em inherit } }

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

// -------------------------------------------------------- // Position "primary" navigation links // -------------------------------------------------------- ! .position-nav (@index) when (@index =< @offset) { li:nth-child(@{index}) { top: unit(@logo-height + (@nav-size * (@index - 2)), em); } ! .position-nav(@index + 1); } .position-nav (@index) when (@index > @offset) { .position-more(@index); } ! .position-more(@index) when (@index > @min-offset) { .more { top: unit(@logo-height + (@nav-size * (@index - 2)), em); } }

Slide 64

Slide 64 text

nav { li:first-child { .highlight(@logo-height); top: 0; img { max-width: 100%; } } li:nth-child(-n+@{min-offset}) { .highlight(); } .position-nav (2); // nth-child to start with }

Slide 65

Slide 65 text

// -------------------------------------------------------- // Generate media queries // -------------------------------------------------------- ! .add-media-query (@index) when (@index > @min-num) { @total-nav-height: (@nav-size * @index + @logo-height); @fraction1: (@total-nav-height / 100); @fraction2: (@nav-font-size * 100); @root: unit((@fraction1 * @fraction2), em); … }

Slide 66

Slide 66 text

.add-media-query (@index) when (@index > @min-num) { … ! nav { @media screen and (min-height: @root) { li:nth-child(-n+@{index}) { .highlight() } } ! @media screen and (max-height: @root) { .position-more(@index); } } .add-media-query(@index - 1); } ! .add-media-query (0) {} .add-media-query (@offset);

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

WHAT ELSE CAN WE DO? Single Page Navigation Galleries Scrolling Sites Takeovers

Slide 69

Slide 69 text

EMBRACE THE VERTICAL @aebsr hzdg.com