久久久久久久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 選擇器的工具?)
主站蜘蛛池模板: 亚洲一卡二卡 | 国产精品美女久久久久久不卡 | 97精品国产97久久久久久免费 | 欧美激情在线一区二区三区 | 麻豆av网| 在线亚洲人成电影网站色www | 欧美精品欧美精品系列 | 国产午夜精品久久久 | 国产精品一区二区不卡 | 国产精品久久久久久中文字 | 国产精品久久久精品 | 精品91| 日韩精品极品视频在线观看免费 | 国产精品黄视频 | 亚洲欧美一区二区三区情侣bbw | 欧美一级免费看 | 中日韩毛片 | 91精品国产手机 | 一级片片| 日韩欧美一区二区三区在线播放 | 欧美精品在线视频 | 欧美一区二区三区一在线观看 | 欧洲亚洲一区 | 欧一区二区| 国产乱码精品一区二区三区忘忧草 | 日韩视频中文字幕 | 欧美free性 | 九九色综合 | 亚洲成人激情在线观看 | 国产成人精品久久二区二区91 | 国产精品久久久久久久久久久久久 | 久久精品国产一区二区三区 | 99久久久久久 | 97视频精品 | 91在线视频精品 | 国产h在线 | 日韩精品在线一区 | 国产一区二区三区在线 | 亚洲入口 | 久久高清 | 黄色网络在线观看 |