一道关于CSS选择器优先级的题

来源:互联网 发布:sql serve case 编辑:程序博客网 时间:2024/04/26 10:35
<span style="font-size:14px;"><html>  <head>    <style type="text/css">        #redP p {             /* 权值 = 100+1=101 */             color:#F00;  /* 红色 */        }         #redP .red em {             /* 权值 = 100+10+1=111 */             color:#00F; /* 蓝色 */         }         #redP p span em {             /* 权值 = 100+1+1+1=103 */             color:#FF0;/*黄色*/        }    </style>  </head>  <body>     <div id="redP">        <p class="red">red           <span><em>em red</em></span>        </p>        <p>red</p>     </div>  </body></html></span>

点击看看效果是不是跟你想的一样
1 0
原创粉丝点击