Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSS Study Group 1

Kerrick Long
November 06, 2014

CSS Study Group 1

Kerrick Long

November 06, 2014
Tweet

More Decks by Kerrick Long

Other Decks in Programming

Transcript

  1. SELECTORS & RULES,
    CSS STUDY GROUP
    INHERITANCE & SPECIFICITY

    View full-size slide

  2. Kerrick Long
    Things I make and do Where to find me online
    meetup.com/STLEmber
    Lead Front-end Developer
    at Second Street
    www.KerrickLong.com
    twitter.com/KerrickLong
    github.com/Kerrick

    View full-size slide

  3. selector {
    property: value;
    property: value;
    }

    View full-size slide

  4. SELECTORS & RULES
    SELECTORS

    View full-size slide

  5. CSS SELECTORS
    HTML ELEMENTS
    SELECT

    View full-size slide

  6. BASIC SELECTORS
    class="hello world"
    id="intro"
    >
    Example

    * /* Universal */
    h1 /* Type */
    .hello /* Class */
    .world /* Class */
    #intro /* ID */

    View full-size slide

  7. MULTIPLE SELECTORS
    class="hello world"
    id="intro"
    >
    Example

    h1#intro
    #intro.world
    .hello.world
    .world.hello
    h1.hello

    View full-size slide

  8. ATTRIBUTE SELECTORS
    class="hello world"
    id="intro"
    data-foo="bar-qux"
    data-bar="foo baz"
    >
    Example

    h1[data-foo]
    h1[data-foo="bar-qux"]
    h1[data-bar~="baz"]
    h1[data-foo|="bar"]
    h1[data-foo^="b"]
    h1[data-bar$="z"]
    h1[data-foo*="ar"]

    View full-size slide


  9. Example

    a:link
    a:visited
    a:hover
    a:active
    a:focus
    PSEUDO-CLASS SELECTORS

    View full-size slide


  10. type="checkbox" />
    input:disabled
    input:enabled
    input:checked
    PSEUDO-CLASS SELECTORS

    View full-size slide

  11. h1:first-of-type
    h1:last-of-type
    h1:only-of-type
    h1:nth-of-type(5)
    h1:first-child
    h1:last-child
    h1:only-child
    h1:nth-child(3)
    PSEUDO-CLASS SELECTORS

    View full-size slide

  12. PSEUDO-CLASS SELECTORS

    Example


    h1:not(.hello)
    h2:empty

    View full-size slide

  13. PSEUDO-ELEMENTS
    Example

    ::before
    Example
    ::after

    Example
    Lorem Ipsum…
    h2::before
    h2::after
    p::first-line
    p::first-letter

    View full-size slide

  14. COMBINATORS
    Foo
    Bar
    Baz


    Quux
    Bang
    h1 h3 /* Descendant */
    h1 > h2 /* Child */
    h1 + h4 /* Adjacent
    Sibling */
    h1 ~ h6 /* General
    Sibling */

    View full-size slide

  15. SELECTORS & RULES
    RULES

    View full-size slide

  16. CSS RULES
    SPECIFIC STYLES
    APPLY

    View full-size slide

  17. selector
    }
    property: value;
    property: value;

    View full-size slide

  18. BACKGROUND PROPERTIES
    background-color
    background-image
    background-repeat
    background-attachment
    background-position
    /* Short-hand */
    background

    View full-size slide

  19. BACKGROUND PROPERTIES
    background-color
    background-image
    background-repeat
    background-attachment
    background-position
    /* Short-hand */
    background

    View full-size slide

  20. COLOR PROPERTIES
    color
    opacity

    View full-size slide

  21. TEXT PROPERTIES
    text-align
    text-decoration
    text-indent
    text-transform
    line-height
    letter-spacing
    word-spacing
    white-space

    View full-size slide

  22. FONT PROPERTIES
    font-family
    font-style
    font-variant
    font-weight
    font-size
    /* Short-hand */
    font

    View full-size slide

  23. WIDTH
    MARGIN BORDER PADDING CONTENT
    CONTENT-BOX

    View full-size slide

  24. WIDTH
    MARGIN BORDER PADDING CONTENT
    BORDER-BOX

    View full-size slide

  25. BORDER PROPERTIES
    border-width
    border-(TRBL)-width
    border-color
    border-(TRBL)-color
    border-style
    border-(TRBL)-style
    /* Short-hand */
    border

    View full-size slide

  26. MARGIN PROPERTIES
    margin-top
    margin-right
    margin-bottom
    margin-left
    /* Short-hand */
    margin
    /* TRBL - Trouble! */
    margin: 1px 2px 3px 4px;
    margin: 1px 2px;
    margin: 1px;

    View full-size slide

  27. PADDING PROPERTIES
    padding-top
    padding-right
    padding-bottom
    padding-left
    /* Short-hand */
    padding
    /* TRBL - Trouble! */
    padding: 1px 2px 3px 4px;
    padding: 1px 2px 3px;
    padding: 1px 2px;
    padding: 1px;

    View full-size slide

  28. LIST PROPERTIES
    list-style-type
    list-style-image
    list-style-position
    /* Short-hand */
    list-style

    View full-size slide

  29. BOX SIZE PROPERTIES
    width
    min-width
    max-width
    height
    min-height
    max-height

    View full-size slide

  30. VISUAL PROPERTIES
    display
    float
    clear
    overflow
    cursor
    position
    top
    right
    bottom
    left

    View full-size slide

  31. INHERITANCE & SPECIFICITY
    INHERITANCE

    View full-size slide

  32. INHERITANCE
    Foo
    Bar
    Baz


    Quux
    Bang
    h1 {
    color: red;
    }

    View full-size slide

  33. INHERITANCE & SPECIFICITY
    SPECIFICITY

    View full-size slide

  34. SPECIFICITY
    0 0 0 0
    STYLE="" #ID TYPE
    .CLASS,
    :PSEUDO-CLASS
    MOST SPECIFIC LEAST SPECIFIC

    View full-size slide

  35. 0 1 3 1
    STYLE="" #ID TYPE
    .CLASS,
    :PSEUDO-CLASS
    a#login.active.button:hover

    View full-size slide

  36. 0 2 0 0
    STYLE="" #ID TYPE
    .CLASS,
    :PSEUDO-CLASS
    #header img#logo

    View full-size slide

  37. 0 2 0 0
    0 1 3 1
    WHICH IS MORE SPECIFIC?

    View full-size slide

  38. 0 2 0 0
    0
    WHICH IS MORE SPECIFIC?

    View full-size slide