Home > Web Front-end > HTML Tutorial > Detailed explanation of css class selector class name override priority instance

Detailed explanation of css class selector class name override priority instance

零下一度
Release: 2017-06-24 13:47:56
Original
2315 people have browsed it
  • code

    <style>
       .a{
      background: red;
       }
       .b{
      background: yellow;
       }
    </style>
    <div class="a b">A</div>
    Copy after login
  • Rendering effect
    Detailed explanation of css class selector class name override priority instance

    At first I thought I would change the order of the class names in the class class in the element. The rendering effects will be rendered in sequence according to the class name

  • code

    <style>
       .a{
      background: red;
       }
       .b{
      background: yellow;
       }
    </style>
    <div class="b a">A</div>
    Copy after login
  • Rendering effects
    Detailed explanation of css class selector class name override priority instance

    Changing the order of the class names in the element class does not affect the rendering order

  • code

       <style>
       .b{
      background: yellow;
       }
       .a{
      background: red;
       }
       </style>
    <div class="a b">A</div>
    Copy after login
  • Rendering effect
    Detailed explanation of css class selector class name override priority instance

    Changing the order of classes in the style sheet will affect the rendering order

    Conclusion: The two classes have the same attribute coverage order, which is the order from bottom to top in the css style sheet

The above is the detailed content of Detailed explanation of css class selector class name override priority instance. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template