Slide 1

Slide 1 text

Salma Alam-Naylor @whitep4nth3r THIS BOX WILL CHANGE YOUR LIFE.

Slide 2

Slide 2 text

@whitep4nth3r https://whitep4nth3r.com HI FRIENDS, I’M SALMA. I help developers build stuff, learn things, and love what they do.

Slide 3

Slide 3 text

No content

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

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

WHAT IS CSS?

Slide 16

Slide 16 text

Cascading Style Sheet CSS

Slide 17

Slide 17 text

Cascade CSS

Slide 18

Slide 18 text

Specificity CSS Cascade

Slide 19

Slide 19 text

CSS Specificity Cascade Inheritance

Slide 20

Slide 20 text

CSS Specificity Cascade Inheritance An algorithm that defines how to combine CSS property values from different sources.

Slide 21

Slide 21 text

CSS Specificity Cascade Inheritance How browsers decide which CSS property values are the most relevant to an element and, therefore, will be applied. An algorithm that defines how to combine CSS property values from different sources.

Slide 22

Slide 22 text

CSS Specificity Cascade Inheritance Default > parent > child. An algorithm that defines how to combine CSS property values originating from different sources. How browsers decide which CSS property values are the most relevant to an element and, therefore, will be applied.

Slide 23

Slide 23 text

CSS Inheritance Default > parent > child.

Slide 24

Slide 24 text

CSS YOU

Slide 25

Slide 25 text

YOU CSS

Slide 26

Slide 26 text

//* HTML **/
<

Slide 27

Slide 27 text

//* HTML **/
<
//* CSS **/ .container { max-width: 640px; margin: auto; border: 10px solid red; }

Slide 28

Slide 28 text

//* HTML **/
<
//* CSS **/ .container { max-width: 640px; margin: auto; border: 10px solid red; }

Slide 29

Slide 29 text

//* HTML **/
<
//* CSS **/ .container { max-width: 640px; margin: auto; border: 10px solid red; }

Slide 30

Slide 30 text

//* HTML **/
<
//* CSS **/ .container { max-width: 640px; margin: auto; border: 10px solid red; }

Slide 31

Slide 31 text

//* HTML **/
<
<

Slide 32

Slide 32 text

//* HTML **/
<
<
//* CSS **/ .box { background: yellow; border: 10px solid blue; }

Slide 33

Slide 33 text

//* HTML **/
<
<
//* CSS **/ .box { background: yellow; border: 10px solid blue; }

Slide 34

Slide 34 text

//* HTML **/
<
<
//* CSS **/ .box { background: yellow; border: 10px solid blue; }

Slide 35

Slide 35 text

//* HTML **/
<
<
//* CSS **/ .box { background: yellow; border: 10px solid blue; padding: 20px; }

Slide 36

Slide 36 text

//* HTML **/

This is a box.<

<
<

Slide 37

Slide 37 text

//* HTML **/

This is a box.<

<
<

Slide 38

Slide 38 text

//* CSS **/ .box { background: yellow; border: 10px solid blue; padding: 20px; width: 100%; }

Slide 39

Slide 39 text

//* CSS **/ .box { background: yellow; border: 10px solid blue; padding: 20px; width: 100%; }

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

//* CSS **/ .box { background: yellow; border: 10px solid blue; padding: 20px; width: 100%; box-sizing: border-box; }

Slide 43

Slide 43 text

//* CSS **/ .box { background: yellow; border: 10px solid blue; padding: 20px; width: 100%; box-sizing: border-box; }

Slide 44

Slide 44 text

The CSS Box Model

Slide 45

Slide 45 text

The CSS Box Model will change your life.

Slide 46

Slide 46 text

WHAT IS THE CSS BOX MODEL?

Slide 47

Slide 47 text

DESIGN & LAYOUT CSS BOX MODEL

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

CONTENT CSS BOX MODEL

Slide 50

Slide 50 text

PADDING CONTENT CSS BOX MODEL

Slide 51

Slide 51 text

BORDER PADDING CONTENT CSS BOX MODEL

Slide 52

Slide 52 text

MARGIN BORDER PADDING CONTENT CSS BOX MODEL

Slide 53

Slide 53 text

MARGIN BORDER PADDING CONTENT CSS BOX MODEL MARGIN BORDER PADDING CONTENT MARGIN BORDER PADDING CONTENT

Slide 54

Slide 54 text

https://whitep4nth3r.com

Slide 55

Slide 55 text

https://whitep4nth3r.com ← CONTENT →

Slide 56

Slide 56 text

https://whitep4nth3r.com PADDING → ← ← CONTENT →

Slide 57

Slide 57 text

https://whitep4nth3r.com BORDER → PADDING → ← ← CONTENT →

Slide 58

Slide 58 text

https://whitep4nth3r.com BORDER → PADDING → ← ← MARGIN → ← CONTENT →

Slide 59

Slide 59 text

https://whitep4nth3r.com BORDER → PADDING → ← ← MARGIN → ← CONTENT →

Slide 60

Slide 60 text

https://whitep4nth3r.com

Slide 61

Slide 61 text

CSS BOX MODEL

Slide 62

Slide 62 text

CSS BOX MODEL

Slide 63

Slide 63 text

.box { background: yellow; border: 10px solid blue; padding: 20px; width: 100%; box-sizing: border-box; } CSS BOX MODEL

Slide 64

Slide 64 text

.box { background: yellow; border: 10px solid blue; padding: 20px; width: 100%; box-sizing: border-box; } CSS BOX MODEL

Slide 65

Slide 65 text

WHAT IS BOX-SIZING?

Slide 66

Slide 66 text

BOX-SIZING The box-sizing property defines how the width and height of an element are calculated.

Slide 67

Slide 67 text

BOX-SIZING The box-sizing property defines how the width and height of an element are calculated.

Slide 68

Slide 68 text

BOX-SIZING

Slide 69

Slide 69 text

BOX-SIZING

Slide 70

Slide 70 text

BOX-SIZING box-sizing: border-box;

Slide 71

Slide 71 text

BOX-SIZING box-sizing: border-box;

Slide 72

Slide 72 text

BOX-SIZING box-sizing: border-box; box-sizing: content-box;

Slide 73

Slide 73 text

box-sizing: content-box; BOX-SIZING

Slide 74

Slide 74 text

box-sizing: content-box; BOX-SIZING BROW SER DEFAULT

Slide 75

Slide 75 text

BOX-SIZING box-sizing: content-box; .box { //* No box-sizing specified **/ background: black; color: yellow; border: 10px solid blue; padding: 20px; width: 100%; }

Slide 76

Slide 76 text

BOX-SIZING box-sizing: content-box; .box { //* No box-sizing specified **/ background: black; color: yellow; border: 10px solid blue; padding: 20px; width: 100%; } CALCULATED WIDTH 100%

Slide 77

Slide 77 text

BOX-SIZING box-sizing: content-box; .box { //* No box-sizing specified **/ background: black; color: yellow; border: 10px solid blue; padding: 20px; width: 100%; } CALCULATED WIDTH 100% + 20PX

Slide 78

Slide 78 text

BOX-SIZING box-sizing: content-box; CALCULATED WIDTH 100% + 20PX + 10PX .box { //* No box-sizing specified **/ background: black; color: yellow; border: 10px solid blue; padding: 20px; width: 100%; }

Slide 79

Slide 79 text

BOX-SIZING box-sizing: border-box; .box { box-sizing: border-box; background: yellow; color: black; border: 10px solid blue; padding: 20px; width: 100%; }

Slide 80

Slide 80 text

BOX-SIZING box-sizing: border-box; .box { box-sizing: border-box; background: yellow; color: black; border: 10px solid blue; padding: 20px; width: 100%; } CALCULATED WIDTH 100%

Slide 81

Slide 81 text

BOX-SIZING box-sizing: border-box; .box { box-sizing: border-box; background: yellow; color: black; border: 10px solid blue; padding: 20px; width: 100%; } CALCULATED WIDTH 100%

Slide 82

Slide 82 text

BOX-SIZING box-sizing: border-box; .box { box-sizing: border-box; background: yellow; color: black; border: 10px solid blue; padding: 20px; width: 100%; } CALCULATED WIDTH 100%

Slide 83

Slide 83 text

THE PROBLEM WITH CSS RESETS

Slide 84

Slide 84 text

CSS RESETS A CSS reset is a set of CSS rules that resets the styling of all HTML elements to a consistent baseline*.

Slide 85

Slide 85 text

A CSS reset is a set of CSS rules that resets the styling of all HTML elements to a consistent baseline*. CSS RESETS *probably opinionated

Slide 86

Slide 86 text

undohtml.css CSS RESETS

Slide 87

Slide 87 text

undohtml.css CSS RESETS HTML5 Reset

Slide 88

Slide 88 text

undohtml.css CSS RESETS HTML5 Reset Normalize.css

Slide 89

Slide 89 text

undohtml.css CSS RESETS HTML5 Reset Normalize.css Sanitize.css

Slide 90

Slide 90 text

undohtml.css CSS RESETS HTML5 Reset Normalize.css Sanitize.css MiniReset.css

Slide 91

Slide 91 text

undohtml.css CSS RESETS HTML5 Reset Normalize.css Sanitize.css MiniReset.css Reboot

Slide 92

Slide 92 text

CSS RESETS * { box-sizing: border-box; }

Slide 93

Slide 93 text

CSS RESETS * { box-sizing: border-box; }

Slide 94

Slide 94 text

* { box-sizing: border-box; } CSS RESETS ← EVERY SINGLE ELEMENT

Slide 95

Slide 95 text

https://css-tricks.com/reboot-resets-reasoning/

Slide 96

Slide 96 text

CSS RESETS Understand the behaviour of your boxes.

Slide 97

Slide 97 text

https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing

Slide 98

Slide 98 text

https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing

Slide 99

Slide 99 text

CSS RESETS Know what you want to achieve.

Slide 100

Slide 100 text

UNDERSTANDING BROWSER DEFAULTS

Slide 101

Slide 101 text

BROWSER DEFAULTS YOU

Slide 102

Slide 102 text

YOU BROWSER DEFAULTS

Slide 103

Slide 103 text

User Agent Style Sheet BROWSER DEFAULTS

Slide 104

Slide 104 text

BROWSER DEFAULTS: CHROMIUM

Slide 105

Slide 105 text

BROWSER DEFAULTS: FIREFOX

Slide 106

Slide 106 text

BROWSER DEFAULTS: FIREFOX

Slide 107

Slide 107 text

BROWSER DEFAULTS: FIREFOX

Slide 108

Slide 108 text

BROWSER DEFAULTS: SAFARI

Slide 109

Slide 109 text

BROWSER DEFAULTS //* HTML **/

This is a box.<

<
<

Slide 110

Slide 110 text

BROWSER DEFAULTS //* HTML **/

This is a box.<

<
<

Slide 111

Slide 111 text

BROWSER DEFAULTS //* HTML **/

This is a box.<

<
<
//* HTML **/

This is a box.<

<
<

Slide 112

Slide 112 text

BROWSER DEFAULTS

Slide 113

Slide 113 text

BROWSER DEFAULTS

Slide 114

Slide 114 text

BROWSER DEFAULTS

Slide 115

Slide 115 text

BROWSER DEFAULTS

Slide 116

Slide 116 text

BROWSER DEFAULTS

Slide 117

Slide 117 text

DIFFERENT TYPES OF BOXES

Slide 118

Slide 118 text

DIFFERENT BOXES BLOCK

Slide 119

Slide 119 text

DIFFERENT BOXES BLOCK INLINE

Slide 120

Slide 120 text

DIFFERENT BOXES BLOCK INLINE INLINE-*

Slide 121

Slide 121 text

DIFFERENT BOXES BLOCK

Slide 122

Slide 122 text

DIFFERENT BOXES BLOCK BLOCK

Slide 123

Slide 123 text

DIFFERENT BOXES BLOCK BLOCK BLOCK

Slide 124

Slide 124 text

DIFFERENT BOXES BLOCK BLOCK BLOCK

Slide 125

Slide 125 text

DIFFERENT BOXES INLINE

Slide 126

Slide 126 text

DIFFERENT BOXES INLINE INLINE

Slide 127

Slide 127 text

DIFFERENT BOXES INLINE INLINE INLINE

Slide 128

Slide 128 text

DIFFERENT BOXES INLINE INLINE INLINE

Slide 129

Slide 129 text

DIFFERENT BOXES INLINE INLINE INLINE INLINE INLINE INLINE

Slide 130

Slide 130 text

DIFFERENT BOXES INLINE-* INLINE-* INLINE-* INLINE-* INLINE-* INLINE-*

Slide 131

Slide 131 text

Box type block inline-* inline Breaks onto a new line ✅ ❌ ❌ Fills horizontal space ✅ ❌ ❌ Width + height ✅ ✅ ❌ Push vertical padding + margin + borders ✅ ✅ ❌ Push horizontal padding + margin + borders ✅ ✅ ✅ DIFFERENT BOXES

Slide 132

Slide 132 text

DIFFERENT BOXES

Slide 133

Slide 133 text

Solve all your problems with this one simple trick! BROWSER DEFAULTS

Slide 134

Slide 134 text

Always declare display. BROWSER DEFAULTS

Slide 135

Slide 135 text

Always declare display. BROWSER DEFAULTS Always declare everything.

Slide 136

Slide 136 text

WRAPPING UP

Slide 137

Slide 137 text

CSS BOX MODEL

Slide 138

Slide 138 text

CSS BOX MODEL

Slide 139

Slide 139 text

Think inside the box. THIS BOX WILL CHANGE YOUR LIFE

Slide 140

Slide 140 text

Content + Padding + Border THIS BOX WILL CHANGE YOUR LIFE Think inside the box.

Slide 141

Slide 141 text

Think outside the box. THIS BOX WILL CHANGE YOUR LIFE

Slide 142

Slide 142 text

Margin THIS BOX WILL CHANGE YOUR LIFE Think outside the box.

Slide 143

Slide 143 text

Think about the box. THIS BOX WILL CHANGE YOUR LIFE

Slide 144

Slide 144 text

Block THIS BOX WILL CHANGE YOUR LIFE Think about the box.

Slide 145

Slide 145 text

Block / Inline THIS BOX WILL CHANGE YOUR LIFE Think about the box.

Slide 146

Slide 146 text

The CSS Box Model will change your life. THIS BOX WILL CHANGE YOUR LIFE

Slide 147

Slide 147 text

👋 COME AND SAY HI!

Slide 148

Slide 148 text

BUILD STUFF, LEARN THINGS, LOVE WHAT YOU DO. @whitep4nth3r

Slide 149

Slide 149 text

THANK YOU! @whitep4nth3r https://whitep4nth3r.com