Leilin Peng Share: CSS selectors and nested grouping

  A packet selector

  There are a lot of elements with the same style in the style sheet.

  h1

  {

  color:green;

  }

  h2

  {

  color:green;

  }

  p

  {

  color:green;

  }

  To minimize the code, you can use the packet selector.

  Used for each selection separated by commas.

  In the following example, we use a bank selector code for the above:

  Examples

  h1,h2,p { color:green; }

  Nested selector

  It may apply to selectors inside the Style Selector.

  In the following three examples set style:

  p {}: Specifies a style for all p elements.

  .marked {}: for all class = "marked" element specifies a pattern.

  .marked p {}: = p elements within the "marked" element specifies a style for all class.

  p.marked {}: for all class = "marked" element specifies a pattern of p.

  Examples

  p {color: blue; text-align: center;} .marked {background-color: red;} .marked p {color: white;} p.marked {text-decoration: underline;} (Editor: Leilin Peng Source : network intrusion deleted)

Guess you like

Origin www.cnblogs.com/pengpeng1208/p/11238277.html