css introduction method and selector type

1. Three ways to introduce css

  Inline, embedded, external. External optimal

  Inline is not easy to maintain and code cannot be reused

  Embedded code cannot be reused by multiple files

2. css commonly used selector

  grammar:

    Selector {

      Attribute: value

    }

  Function: Select the corresponding label on the page and set the corresponding style

  -Basic selector

    + Tag selector

      * Set common attributes for the same elements on the page

    + id selector

      * Any element can be set id

      * id is unique, which means that the selected element is characteristic

    + Class selector

      * Any element can be set to class

      * Multiple classes can be set in an element

      * There must be "the concept of classification, public category". Select the elements of the page and set the same attributes

   -Advanced selector

     + Descendant selector (dad's son, grandson ...)

        * div p{}

     + Child selector

        * div>p{}

     + Combination selector

        * Selector 1, Selector 2, Selector 3 {}

     + Intersection selector

        * div.p{}

     + Pseudo class selector

        * a tag

          -LoVe HAte

            The original attribute of the a: link {} tag

            a: visited {} visited tags

            a: hover {} when hovering over the label

            a: activate {} When holding the label

        hover can be applied to any element 

  

 

Guess you like

Origin www.cnblogs.com/jet-chen/p/12719575.html