Slide 1

Slide 1 text

102 Layout Box model Content flow Positioning Weirdness

Slide 2

Slide 2 text

box model

Slide 3

Slide 3 text

box model content box < padding box < border box < margin box

Slide 4

Slide 4 text

box model clockwise from the top top right bottom left img { margin: 10px 5px 0px 20px; }

Slide 5

Slide 5 text

content box determined by text or fixed size p { font-size: 14pt; line-height: 1.5; font-family: "Helvetica Neue"; } img { width: 300px; height: 150px; }

Slide 6

Slide 6 text

padding box adds a gap between content and border, makes it easier to click elements button { padding: 20px; }

Slide 7

Slide 7 text

border box width, style, color header { border: 8px solid gold; }

Slide 8

Slide 8 text

adds a gap between border and other boxes img { margin: 25px; } margin box

Slide 9

Slide 9 text

content flow

Slide 10

Slide 10 text

1. Left to right 2. Top to bottom

Slide 11

Slide 11 text

Floats: easy to abuse, better to avoid Useful mostly for images in a blog post Absolute/fixed positioning: Choose the top, right, bottom, or left distance from a container or viewport. Take it out of the flow

Slide 12

Slide 12 text

positioning X/Y axis: left to right, top to bottom Reference: static, fixed, relative, absolute

Slide 13

Slide 13 text

weirdness Negative margin Overlapping z-index Cut off overflow