国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

CSS基礎(chǔ)教程之優(yōu)先級(jí)

CSS優(yōu)先級(jí)


單個(gè)選擇器的優(yōu)先級(jí)

行內(nèi)樣式 > id選擇器 > ?class選擇器 > 標(biāo)簽選擇器

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>php.cn</title>
    <style type="text/css">
     h1{
         color:green;
     }
    .hclass{
        color:bule;
    }
    #hid{
        color:black;
    }
    </style>
    </head>
    <body>
        <div>
        <h1 class="hclass" id="hid"  style="color:red">習(xí)近平心中的互聯(lián)網(wǎng)</h1>
        </div>
    </body>
</html>

利用firebug觀察:

26.png



多個(gè)選擇器的優(yōu)先級(jí)

多個(gè)選擇器的優(yōu)先級(jí),一般情況下,指向越準(zhǔn)確,優(yōu)先級(jí)越高。

特殊情況下,我們需要假設(shè)一些值:

  • 標(biāo)簽選擇器 ?????優(yōu)先級(jí)為1

  • 類(lèi)選擇器 ???????優(yōu)先級(jí)為10

  • Id選擇器 ???????優(yōu)先級(jí)為100

  • 行內(nèi)樣式 ???????優(yōu)先級(jí)為1000

計(jì)算以下優(yōu)先級(jí)

.news h1{color:red;}?????優(yōu)先級(jí):10 + 1 = 11

.title{color:blue;}????????優(yōu)先級(jí):10

div.news h1{color:red;}???優(yōu)先級(jí):1 + 10 + 1 = 12

h1.title{color:blue;}??????優(yōu)先級(jí):1 + 10 = 11


繼續(xù)學(xué)習(xí)
||
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <style type="text/css"> h1{ color:green; } .hclass{ color:bule; } #hid{ color:black; } </style> </head> <body> <div> <h1 class="hclass" id="hid" style="color:red">習(xí)近平心中的互聯(lián)網(wǎng)</h1> </div> </body> </html>
提交重置代碼