久久久久久久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精品免费视频 | h在线免费观看 | 99国产精品视频免费观看一公开 | 亚洲三区视频 | 成人国内精品久久久久一区 | av一区在线观看 | 男女羞羞在线观看 | 亚洲午夜精品一区二区三区他趣 | 久久精品成人 | 久久精品国产免费 | 免费在线观看黄网站 | 亚洲激情在线观看 | 国产中文视频 | 成人欧美一区二区三区黑人孕妇 | 国产毛片毛片 | 日韩欧美在线观看视频网站 | 亚洲精品九九 | www.youjizz.com日韩| av天天看| 欧美视频二区 | 国产精品久久久久久久久久久新郎 | 成人国产精品视频 | av永久 | 欧美美女爱爱 | 精品国产免费人成在线观看 | av在线一区二区三区 | 国产精品亚洲综合 | 99精品久久 | 久久久久中文字幕 | 在线视频 中文字幕 | 欧美精品一区在线发布 | 91亚洲精华国产 | 色综合九九 | 日韩欧美在线一区 | 夜夜夜夜夜夜曰天天天 | 亚洲免费在线观看 | 超碰成人在线观看 | 伊人狠狠 | 天堂色网 |