CSS - crash course in Selectors, box model, Idan Gazit

Get Started. It's Free
or sign up with your email address
Rocket clouds
CSS - crash course in Selectors, box model, Idan Gazit by Mind Map: CSS - crash course in Selectors, box model, Idan Gazit

1. A deep dive

1.1. 2 topics that are the heart of CSS

2. Selectors

2.1. h1 {...}

2.1.1. h1 - selector

2.1.2. {..} - declaration block

2.2. in the begginning there was only

2.2.1. DOM tree

2.2.1.1. relationships

2.2.1.1.1. ancestors - decendants

2.2.1.1.2. parent - child

2.2.1.2. in reality - it's a complex graph, not a simple tree

2.3. selectors allow you to choose on which elements to work

2.4. 5 types

2.4.1. Specific

2.4.1.1. example

2.4.1.1.1. p

2.4.1.1.2. p.large

2.4.1.1.3. #nav

2.4.1.1.4. *

2.4.1.1.5. intro.large

2.4.2. Hierarchical

2.4.2.1. example

2.4.2.1.1. div p

2.4.2.1.2. div > p

2.4.2.1.3. h1 + p

2.4.2.2. css 3

2.4.2.2.1. div ~ p

2.4.3. Attribute

2.4.3.1. example

2.4.3.1.1. img[alt]

2.4.3.1.2. img[alt="foo"]

2.4.3.1.3. img[alt~="foo"]

2.4.3.1.4. img[alt|="foo"]

2.4.3.2. css 3

2.4.3.2.1. ^=

2.4.3.2.2. $=

2.4.3.2.3. *=

2.4.4. Pseudo-classes

2.4.4.1. like a state

2.4.4.2. example

2.4.4.2.1. :first-child

2.4.4.2.2. :link

2.4.4.2.3. :visited

2.4.4.2.4. :hover

2.4.4.2.5. :active

2.4.4.2.6. :focus

2.4.4.2.7. :lang(foo)

2.4.4.3. actual example

2.4.4.3.1. div>p:first-child

2.4.4.4. css 3

2.4.4.4.1. example

2.4.4.4.2. non work in IE<9

2.4.4.4.3. actual example

2.4.5. Pseudo-elements

2.4.5.1. examples

2.4.5.1.1. :first-line, :first-letter

2.4.5.1.2. :before, :after

2.4.5.2. actual example

2.4.5.2.1. li.optional:before

2.5. Specifity

2.5.1. meaning

2.5.1.1. how "specific" the elements definition

2.5.1.2. you can understand the rules order by logic

2.5.2. law

2.5.2.1. later rules trump earlier rules if their of the same specifity

2.5.2.1.1. see spec

2.5.3. rules of specifity (in this order)

2.5.3.1. style

2.5.3.2. id's

2.5.3.3. attributes, classes, peseudo-classes

2.5.3.4. elements, pseudo-classes

2.5.4. this is translates to number prefixes, in order for the browser to process

2.5.5. Firebug & chrome debugger presents the specifity

2.6. OMG WTF PPK

2.6.1. quirksmode.org/css/contents.html

2.6.2. support of anything in each browser

2.7. performance

2.7.1. Steve Sauders says if you don't have 40K elements, no meaningful overhead in performance

3. The Box Model

3.1. about

3.1.1. doesn't work the way you expect

3.1.1.1. wtf

3.2. wtf 1

3.2.1. width & height apply just to the inner area, not including the padding & border

3.2.2. math

3.2.2.1. size + padding (both sides) + border (both sides) = actual size

3.2.3. more math

3.2.3.1. auto width

3.2.3.1.1. containing block - margin - border - padding = calculated width

3.3. wtf 2

3.3.1. margin collapsing

3.3.1.1. higher size takes over smaller

3.4. read the spec

3.4.1. w3c.org/TR/CSS/box.html

4. slides

4.1. http://db.tt/D7TAX6X