久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

CSS 類重復以增加特異性

CSS class repetition to increase specificity(CSS 類重復以增加特異性)
本文介紹了CSS 類重復以增加特異性的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

根據 CSS 文檔:http://www.w3.org/TR/CSS21/cascade.html#specificity

特異性由(除其他外)選擇器中屬性和偽類的數量定義.

Specificity is defined by (amongst other things) the number of attributes and pseudo-classes in the selector.

所以,我的問題是,是否可以通過一遍又一遍地重復相同的類名來增加特異性?

So, my question is, is it possible to increase specificity by repeating the same classname over and over again?

例如:

.qtxt.qtxt.qtxt.qtxt.qtxt
{
}

.qtxt.lalgn
{
}

.lalgn .qtxt//(space added to create child selector)
{
}

?

推薦答案

是的,這是可能的,也是有意的.雖然 CSS2 規范中沒有提到這一點,但在 Selectors 3 規范中明確提到了這一點:

Yes, it is possible and intentionally so. While this is not mentioned in the CSS2 spec, it is explicitly mentioned in the Selectors 3 spec:

注意:允許重復出現 [sic] 相同的簡單選擇器,這樣做會增加特異性.

Note: Repeated occurrances [sic] of the same simple selector are allowed and do increase specificity.

因此瀏覽器必須在遇到重復的簡單選擇器時增加特異性,只要選擇器有效且適用.這不僅適用于重復的類,也適用于重復的 ID、屬性和偽類.

Therefore browsers must increase the specificity when encountering repeated simple selectors, as long as the selector is valid and applicable. This not only applies to repeated classes, but also applies to repeated IDs, attributes and pseudo-classes.

根據您的代碼,.qtxt.qtxt.qtxt.qtxt.qtxt 將具有最高的特異性.其他兩個選擇器同樣具體;組合子根本不影響特異性計算:

Given your code, .qtxt.qtxt.qtxt.qtxt.qtxt will have the highest specificity. The other two selectors are equally specific; combinators have no bearing in specificity calculations at all:

/* 5 classes -> specificity = 0-5-0 */
.qtxt.qtxt.qtxt.qtxt.qtxt

/* 2 classes -> specificity = 0-2-0 */
.qtxt.lalgn

/* 2 classes -> specificity = 0-2-0 */
.lalgn .qtxt

另外,最后一個選擇器中的空格是 descendant 組合子;child 組合子是 >.

Also, the space in your last selector is the descendant combinator; the child combinator is >.

這篇關于CSS 類重復以增加特異性的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Style every third element?(每隔三個元素設置樣式?)
Why shouldn#39;t I use ID selectors in CSS?(為什么我不應該在 CSS 中使用 ID 選擇器?)
What does img[class*=quot;alignquot;] mean in CSS?(CSS 中的 img[class*=“align] 是什么意思?)
CSS: Last element on line(CSS:最后一個元素)
How do I select every other div class element using just CSS (no js)(如何僅使用 CSS(無 js)選擇所有其他 div 類元素)
Tool for checking unused CSS selectors?(檢查未使用的 CSS 選擇器的工具?)
主站蜘蛛池模板: 成人综合一区二区 | 精品亚洲一区二区三区 | 一区二区三区小视频 | 色就干 | 国产午夜三级一区二区三 | 午夜视频在线免费观看 | 日韩精品一区二区不卡 | 国产精品欧美一区二区三区不卡 | 国产粉嫩尤物极品99综合精品 | 国产综合欧美 | 蜜桃黄网 | 欧美精品一区三区 | 韩国毛片一区二区三区 | 中文字幕日韩专区 | v片网站| 久久久久免费精品国产 | 伊人网站视频 | 成人精品一区二区三区 | 毛片久久久 | 国产91久久久久蜜臀青青天草二 | 一本一道久久a久久精品蜜桃 | 久久一区二区视频 | 99国产精品久久久久久久 | 网站黄色在线免费观看 | 精品一区二区三区日本 | 日本天天操 | 一区中文 | 亚洲综合色婷婷 | 五月天国产视频 | 日韩三区 | 久久日韩粉嫩一区二区三区 | av一区二区三区 | 91国在线视频 | 男女网站免费 | 欧美激情精品久久久久久变态 | 色视频一区二区 | 久久不射电影网 | 伊人久久伊人 | 日日日日日日bbbbb视频 | 欧美激情国产精品 | 四虎影院免费在线 |