Priority stacking mechanism and the concept of inheritance and the CSS selectors

Layered mechanisms:

  A property of a particular style elements from the style attribute may be between rows inline style sheets or external style sheets introduced, as well as a custom style browser, there is inherited from the parent element of style, but it will eventually wherein a selected one of said the selection process is called laminating (cascading).

 

Inheritance mechanism:

  In the inheritance mechanism, the style will not only apply to the specified elements, the elements will apply to not set a specific style of its offspring, the descendant elements of his style is inherited from its parent style, but not all of the parent styles will be inherited, usually about writing style will be inherited.

Selector priority:

  ! Important> inline style> id selector> class selector> element selector> wildcard> inherited

  The number of inline style Id number selector The number of class selector The number of elements of the selector
Inline style 1 0 0 0
id selector 0 1 0 0
Class selector, pseudo class selector 0 0 1 0
Element selector, the dummy selector elements 0 0 0 1
Tsuhaifu 0 0 0 0
!important highest highest highest highest

  Priority calculation method: weight; (0,0,0,0)

  The number 0 indicates a first-line, the second number represents the id selector,

  The third class is the number of selectors, the number of elements is the fourth selector,

  Then is the right priority after selecting combinations of multiple heavy, cascading style will choose the right major.

  That style elements will determine the maximum weight by the weight attribute selectors set up inside.

Guess you like

Origin www.cnblogs.com/hg845740143/p/12045413.html