css weight rating

1, the cause of the problem (in an accidental write css found, .div2 p> .div1 p> .p1, and then did a test search to find relevant information)

 

 

2. Solution

  Behold the first high-level weights

  ! 1, important, added after the style property values, the weight value is 10000
  2, the inline style, such as: style = "", weight value is 1000
  . 3, ID selector, such as: #content, weight is 100
  4 type, pseudo-classes and attribute selection, such as: content,: hover weighted value of 10
  5, a tag selector and pseudo-element selectors, such as: div, p,: before the weight is 1
  6, the universal selector (*) , child selector (>), adjacent selector (+), fellow selector (~), weight value is 0

  Therefore, the right weight .div1 p is 10 + 1 = 11, .div2 weight weight of p is 10 + 1 = 11, a weight value of 10 weight .p1

  Look a second distance from the tag near p

  .p1>.div2 p>.div1 p

  Therefore, the above analysis     .div2 p> .div1 p> .p1

 

Guess you like

Origin www.cnblogs.com/M-fengye/p/11735119.html