久久久久久久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 選擇器的工具?)
主站蜘蛛池模板: 欧美自拍视频 | 欧美日韩少妇 | 亚洲一级二级三级 | 日韩成人一区二区 | 一区二区三区免费在线观看 | 夜夜操夜夜爽 | 青青青国产 | 亚洲男人在线 | 国产精品永久久久久久久久久 | 超碰在线看 | www.黄色片 | 久久久精品国产sm调教网站 | 三年中文在线观看免费大全中国 | 一区二区免费看 | 国产成人精品视频 | 亚洲黄色在线观看 | 激情视频网 | 日韩手机看片 | 毛片在线视频 | 激情综合网站 | 91精品国产色综合久久不卡98 | 毛片毛片毛片 | 黄色片网站在线观看 | 亚洲h视频 | 成人毛片在线 | 欧美视频免费看 | 成人欧美一区二区三区白人 | 国产成人亚洲精品自产在线 | 欧美在线视频一区 | 日韩不卡在线 | 国产做受网站 | 日本免费黄色 | 成人在线一区二区 | 成年人黄色 | 免费色片| 欧美日本在线观看 | 91蝌蚪91九色白浆 | 在线视频一区二区三区 | 色播av | 一区二区三区免费观看 | 欧美性猛交乱大交 |