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

ID 屬性的屬性選擇器是否不如 ID 選擇器具體?

Is an attribute selector for the ID attribute less specific than an ID selector?(ID 屬性的屬性選擇器是否不如 ID 選擇器具體?)
本文介紹了ID 屬性的屬性選擇器是否不如 ID 選擇器具體?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我需要做些什么才能使 [id^=value] 選擇器具有與常規 ID 相同的特異性,為什么它不等于或大于?(考慮到我也給了它html)

What do I need to do to give the [id^=value] selector the same specificity as a regular ID, and why isn't it equal or greater already? (considering that I gave it html as well)

html div[id^="blue"] {
    background-color: blue
}

#blue4 {
    background-color: red
}

jsfiddle: http://jsfiddle.net/bjwe6yr0/1/

推薦答案

屬性選擇器總是不如 ID 選擇器具體;它的特異性值不會根據屬性名稱而改變.選擇器僅將特定的屬性名稱映射到類選擇器和 ID 選擇器;屬性選擇器是一個通用概念,不包含任何此類映射.

An attribute selector will always be less specific than an ID selector; its specificity value does not change based on the attribute name. Selectors only maps specific attribute names to class selectors and ID selectors; an attribute selector is a generic concept and does not contain any such mappings.

復雜選擇器具有 ID 特異性的唯一方法是它包含一個或多個 ID 選擇器.除了實現限制之外,理論上不可能用任意數量的屬性選擇器或任何其他類型的簡單選擇器覆蓋單個 ID 選擇器.

The only way for a complex selector to have ID specificity is if it contains one or more ID selectors. Implementation limits aside, it is theoretically not possible to override even a single ID selector with any number of attribute selectors or any other type of simple selector.

以下是您的兩個選擇器的比較:

Here is how your two selectors compare:

/* 1 attribute, 2 types -> specificity = 0-1-2 */
html div[id^="blue"] {
    background-color: blue
}

/* 1 ID                 -> specificity = 1-0-0 */
#blue4 {
    background-color: red
}

即使添加 html 也無濟于事,因為它只是一個類型選擇器.將其更改為 :root ,您將獲得一個偽類,它同樣特定于屬性選擇器,因此 仍然 不如 ID 特定.

Even the addition of html doesn't help because it's just a type selector. Change it to :root and you get a pseudo-class which is equally specific to an attribute selector, and thus still less specific than an ID.

這篇關于ID 屬性的屬性選擇器是否不如 ID 選擇器具體?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

CSS selector when :target empty(:target 為空時的 CSS 選擇器)
Does the CSS direct decendant (gt;) not have any value in selectivity?(CSS 直接后代 (gt;) 在選擇性方面沒有任何價值嗎?)
Using querySelectorAll(). Is the result returned by the method ordered?(使用 querySelectorAll().方法返回的結果是否有序?)
Safari bug :first-child doesn#39;t update display:block when items are removed with JS(Safari 錯誤:當使用 JS 刪除項目時,first-child 不更新 display:block)
nth-Child CSS selectors(nth-子 CSS 選擇器)
Using same ID for multiple HTML tags?(對多個 HTML 標簽使用相同的 ID?)
主站蜘蛛池模板: www精品美女久久久tv | 性网站免费 | 国产区高清 | 精品国产乱码久久久久久1区2区 | 天天弄天天操 | 五月婷婷 六月丁香 | 免费视频一区二区 | 免费视频二区 | 久久91精品| 国产乱码精品1区2区3区 | 欧美黑人一区二区三区 | 高清黄色毛片 | 涩涩视频在线播放 | 亚洲国产中文字幕 | 精品国产乱码久久久 | 国产在线对白 | 成年人视频在线免费观看 | 亚州毛片| 久久综合狠狠综合久久综合88 | 三级在线免费观看 | 黄网站涩免费蜜桃网站 | 国产精品久久7777777 | 日韩成人在线网站 | 亚洲国产精品va在线看黑人 | 在线观看视频91 | 欧美日韩国产一区二区三区 | 一级毛片在线播放 | 国产乱码精品1区2区3区 | 美女视频一区 | 观看毛片| 干狠狠| 亚洲精品视频一区二区三区 | 香蕉一区 | 国产精品久久久久久久久久东京 | 国产成人免费视频网站高清观看视频 | 久久狼人天堂 | 久久久精品一区二区三区 | 午夜精品一区二区三区在线视 | 中文字幕视频在线看 | 一区视频 | 日本亚洲欧美 |