Slide 1

Slide 1 text

CSS Layout & Responsive Design Mike Aparicio User Interface Engineer [email protected]

Slide 2

Slide 2 text

Part I • Learn CSS layout methods • Apply CSS layout to personal site Part II • Learn Responsive Web Design basics • Apply RWD principles to personal site

Slide 3

Slide 3 text

http://info.cern.ch/hypertext/WWW/TheProject.html

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

CSS position Property

Slide 11

Slide 11 text

position: static • The default value • Content is positioned in the normal flow of the page

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

position: relative • Content is positioned relative to its normal position • Can adjust position using top, right, bottom, left properties (px, em, rem, %) • Surrounding content does not adjust based on positioning of relative elements • Also used to set position context for absolutely positioned child elements

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

position: fixed • Content is positioned relative to the viewport • Stays in the same place even as the viewport is scrolled • Can adjust position using top, right, bottom, left properties • Does not leave a gap where it would have normally been located on the page (“Removed from the flow”) • Set sufficient margin/padding on content to accommodate fixed elements

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

position: absolute • Content is positioned relative to nearest positioned (not static) ancestor • If no positioned ancestors exist, uses the body element • Scrolls with surrounding content • Can adjust position using top, right, bottom, left properties • Does not leave a gap where it would have normally been located on the page

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

z-index • Positioned elements can overlap • Applying z-index specifies stacking order of elements • Can use positive or negative numbers • Without z-index, element last in HTML markup will be on top

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Centering with margin: auto

Slide 24

Slide 24 text

margin: auto • Block elements will expand to the width of their parent • Applying a width will prevent this (px/em/rem/%) • Setting left and right margins to auto will center horizontally • Using max-width instead of width will make the box flexible up to the max-width value

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

CSS float Property

Slide 27

Slide 27 text

float • Used to wrap text around images • Elements can be floated left or right • Elements after a floated element will flow around it

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

The future present of CSS layout

Slide 41

Slide 41 text

http://caniuse.com/

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

https://css-tricks.com/snippets/css/a-guide-to-flexbox/

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

https://css-tricks.com/snippets/css/complete-guide-grid/

Slide 46

Slide 46 text

Personal Website

Slide 47

Slide 47 text

Layout Cheatsheet Position Properties position: static|absolute*|fixed|relative; top|right|bottom|left: [value in px/ems/rems/%]; z-index: X; * relative to closest positioned ancestor Centering with margin: auto margin: X auto; X = top/bottom margin Float Property float: none|left|right; clear: left; /* clears proceeding element */ overflow: hidden; /* self-clears parent of floated elements */

Slide 48

Slide 48 text

Responsive Web Design

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

Responsive Web Design • Fluid Grid • Flexible Media • Media Queries • (Viewport Meta Tag)

Slide 52

Slide 52 text

Fluid Grid

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

Flexible Media

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

Media Queries

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

Media Queries @media (min-width: 600px) {
 .column {
 flex: 1; } } Apply styles inside declaration when (condition) is met

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

Viewport Meta Tag

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

Personal Website

Slide 72

Slide 72 text

Responsive Cheatsheet Viewport Meta Tag (In Codepen - Settings -> “Insert the most common viewport meta tag”) Flexible Media img { max-width: 100%; } .video { position: relative; padding-bottom: 56.25%; height: 0; } iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } Responsive Grid http://www.responsivegridsystem.com/ Media Queries @media (condition) {
 /* styles to apply when condition is true */ } (max-width, min-width, etc.)

Slide 73

Slide 73 text

Resources • Thinking with Type - Grid (http://www.thinkingwithtype.com/ contents/grid/) • Learn Layout (http://learnlayout.com/) • Responsive Grid System (http://www.responsivegridsystem.com/) • Can I Use? (http://caniuse.com/) • CSS-Tricks (https://css-tricks.com/) • A Book Apart (https://abookapart.com/)

Slide 74

Slide 74 text

Questions? Mike Aparicio [email protected]