好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

CSS样式之优先级-猴子猿

说到到css的样式优先级,今天偶再来回顾下,从css的样式优先级可分为两个部分:

  1、 从CSS代码放置的位置看权重优先级:

   内联样式 > 内部嵌入样式 > 外联样式

  2、 从样式选择器的权重优先级:

   Important > 内联样式 > ID > 类、伪类、属性选择器 > 标签、伪元素 > 通配符

今儿,我们重点来看看第2点—样式选择器。

请看以下代码:

   DOCTYPE html  > 
       head  > 
           title  > css   title  > 
           meta   http-equiv  ="Content-Type"   content  ="text/html; charset=utf-8"  /> 
           style  >      
           div.class1   {  
               background  :  pink  ; 
            }  
           .class2   {  
               background  :  green  ; 
            } 
           style  > 
       head  > 
       body  > 
           div   class  ="class1 class2"   style  ="width:100px;height:100px;"  >  div  > 
       body  > 
   html  >  

查看更多关于CSS样式之优先级-猴子猿的详细内容...

  阅读:33次