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

CSS基礎(chǔ)教學(xué)優(yōu)先級

CSS優(yōu)先權(quán)


#單一選擇器的優(yōu)先級

行內(nèi)樣式> id選擇器> ?class選擇器>標籤選擇器

<!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



多選擇器的優(yōu)先權(quán)

#多個選擇器的優(yōu)先級,一般情況下,指向越準確,優(yōu)先順序越高。

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

  • 標籤選擇器?????優(yōu)先權(quán)為1

  • 類別選擇器優(yōu)先級為10

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

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

計算以下優(yōu)先權(quán)

.news h1{color:red;}?????優(yōu)先權(quán):10 + 1 = 11

.title{color:blue;}優(yōu)先權(quán):10

div.news h1{color:red;}???優(yōu)先權(quán):1 + 10 + 1 = 12

h1.title{color:blue;}??????優(yōu)先權(quán):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>