zoukankan      html  css  js  c++  java
  • [CSS3] Understand CSS Selector Specificity

    It is hard to explain css selector specificty, to easy way to understand it is by playing around with it.

    To remember some rules can be helpful:

    • inline style > ID selector > Classes, attributes, and pseudo-classes > Elements and pseudop elements

    Which means if you have inline style in your html, even you try to use ID selector, it cannot override the inline style. That's why people recommend don't use inline style because it is hard to override.

    • If one combine selector A has more specificty than the other B, A will override B, even B comes later.

    First one is the winner. 

    • If A and B has the same specificity, B comes later win.
    • !Important overrides all the rest. This is the most powerful one, but again it is hard to override in the future if needed, recommended not to use it as much as possible. 
  • 相关阅读:
    php-Zip打包文件
    PHP命令行类库 climate
    vim 添加块注释
    冒泡排序|插入排序
    PHP-SeasLog安装和使用
    链表
    多线程上下文切换
    竞态与线程安全
    线程的生命周期
    线程创建的两种方法
  • 原文地址:https://www.cnblogs.com/Answer1215/p/10100201.html
Copyright © 2011-2022 走看看