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

當瀏覽器不支持 CSS 偽類時會發生什么?

What happens when the browser doesn#39;t support a CSS pseudo-class?(當瀏覽器不支持 CSS 偽類時會發生什么?)
本文介紹了當瀏覽器不支持 CSS 偽類時會發生什么?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如果瀏覽器不支持 CSS 偽類(如 :dir)會怎樣?

What happens if a browser doesn't support a CSS pseudo-class, like :dir?

例如:

html:dir(rtl) {
    color: red;
}

如果瀏覽器不理解 :dir 偽類,他們會忽略這條規則嗎?我對一般情況比對這個特定的偽類更感興趣.我的直覺告訴我是的,但我還沒有找到證實我的直覺的文檔.

Would browsers just ignore this rule if they don't understand the :dir pseudo-class? I'm more interested in the general case then in this particular pseudo-class. My intuition tells me yes, but I haven't found documentation confirming my intuition.

這個問題與這個問題不同:無效的 CSS 選擇器導致規則被丟棄:原因是什么?.它更窄,我問的是瀏覽器在看到它無法識別的偽類時會做什么,而不是它對一般無效的 CSS 選擇器做什么.據我所知,例如,一個無法識別的偽類仍然可能被認為是一個有效的選擇器.

This question is different from this one: Invalid CSS selector causes rule to be dropped: What is the rationale? . It is more narrow, I'm asking what the browser does when it sees a pseudo-class that it doesn't recognise, not what it does for invalid CSS selectors in general. For all I know, an unrecognised pseudo-class may still be considered a valid selector, for instance.

推薦答案

瀏覽器目前不區分 unrecognizedunsupported 選擇器,以及 invalid 選擇器.如果瀏覽器識別出一個選擇器,通常它會盡其所能實現它(并且任何不符合規范的行為都可以在其錯誤跟蹤器上歸類為錯誤),即使它沒有實現所有其他功能在同一級別的選擇器中(例如,當前使用 :dir() 的情況,歷史上 Internet Explorer 7 和 8 具有級別 3 屬性選擇器,以及 Internet Explorer 6 具有通用選擇器).如果它無法識別選擇器,則遵循 CSS2.1 §4.1.7 信守承諾,放棄整個規則集,不問任何問題.注意它說

Browsers currently make no distinction between unrecognized or unsupported selectors, and invalid selectors. If a browser recognizes a selector, generally it'll have implemented it to the best of its ability (and any behavior that's not to spec can be classified as a bug on its bug tracker), even if it doesn't implement all other features in the same level of Selectors (as is currently the case with :dir() for example, and historically Internet Explorer 7 and 8 with level 3 attribute selectors, and Internet Explorer 6 with the universal selector). If it doesn't recognize the selector, it follows CSS2.1 §4.1.7 to the letter and drops the entire ruleset, no questions asked. Notice that it says

當用戶代理無法解析選擇器(即,它不是有效的 CSS 2.1)時,它也必須忽略選擇器和以下聲明塊(如果有).

When a user agent cannot parse the selector (i.e., it is not valid CSS 2.1), it must ignore the selector and the following declaration block (if any) as well.

這意味著如果用戶代理無法解析選擇器,則它必須是無效的 CSS2.1(或在某些其他級別的選擇器中無效);反之,如果它可以解析一個選擇器,那么它一定是有效的.但這假設用戶代理完全符合標準;我們都知道,在現實中,不同的實現對每個標準的符合程度不同,某些實現甚至有自己的供應商特定的選擇器,它們不屬于任何標準.因此,我將其視為當用戶代理無法解析選擇器時"沒有括號,我想瀏覽器供應商也會這樣做.

which implies that if a user agent cannot parse a selector, it must therefore be invalid CSS2.1 (or invalid in some other level of Selectors); and inversely that if it can parse a selector, it must therefore be valid. But this assumes the user agent conforms fully to the standard; we all know that in reality, different implementations have different levels of conformance to each standard, and certain implementations even have their own vendor-specific selectors which are not part of any standard. So I treat this as "When a user agent cannot parse the selector" without the parenthetical, and I imagine browser vendors do the same.

事實上,選擇器本身并沒有區分具有不對應于有效偽類的標識或函數的偽類標記,以及一系列甚至不能被解析為偽類的字符——它們都同樣無效 — 參見 css3-selectors 的第 12 節 和選擇器-4 的第 3.9 節.從本質上講,這意味著當前的瀏覽器行為完全符合標準,而不僅僅是瀏覽器供應商同意的任意決定.

In fact, Selectors itself makes no distinction between a pseudo-class token with an ident or function that doesn't correspond to a valid pseudo-class, and a series of characters that cannot even be parsed as a pseudo-class — they're both equally invalid — see section 12 of css3-selectors and section 3.9 of selectors-4. Essentially, this means that the current browser behavior is in full compliance with the standard, and not just an arbitrary decision agreed upon by browser vendors.

我還沒有聽說過任何瀏覽器將偽類識別為對錯誤處理有效,并繼續忽略該偽類或整個復雜選擇器(將其他復雜選擇器留在選擇器中 -列表不受影響).WebKit 確實有一個非常糟糕的習慣,即接受帶有無法識別的偽元素的 CSS 規則,允許 ::selection、::-moz-selection 之類的東西,其中 被證明是無用的,因為所有其他布局引擎更嚴格地遵循規范.但是,我相信 WebKit 不再這樣做了,但是您知道 WebKit 是如何處理這些事情的.但是 AFAIK 它從來沒有用偽類做到這一點.

I've not heard of any browser that recognizes a pseudo-class as valid for the purposes of error handling, and proceeds to ignore either just that pseudo-class or the entire complex selector (leaving other complex selectors in the selector-list unaffected). WebKit did use to have a really bad habit of accepting CSS rules with unrecognized pseudo-elements, allowing things like ::selection, ::-moz-selection, which proved useless anyway because every other layout engine followed the spec more strictly. I believe WebKit no longer does this, however, but you know how WebKit is with these things. But AFAIK it has never done this with pseudo-classes.

在標準方面,選擇器 4 似乎準備通過引入靜態和動態配置文件來改變這一點.我關于該主題的電子郵件在 CSSWG 中處理電訊;您可以在這里找到會議記錄(搜索不在快速配置文件中的選擇器的行為").但是,已解決的問題是,不在動態(以前是快速)配置文件中的選擇器應該被視為無效,并像往常一樣導致整個 CSS 規則被刪除.請參閱 第 2.1 節:

On the standards side, selectors-4 appears set to change this with the introduction of the static and dynamic profiles. My email on the subject was addressed in a CSSWG telecon; you can find the minutes here (search for "Behavior of Selectors not in Fast Profile"). However, it was resolved that selectors not in the dynamic (previously fast) profile should be treated as invalid and cause the entire CSS rule to be dropped, as usual. See section 2.1:

符合選擇器級別 4 的 CSS 實現必須使用動態配置文件進行 CSS 選擇.使用動態配置文件的實現必須將未包含在配置文件中的選擇器視為未知和無效.

CSS implementations conformant to Selectors Level 4 must use the dynamic profile for CSS selection. Implementations using the dynamic profile must treat selectors that are not included in the profile as unknown and invalid.

這篇關于當瀏覽器不支持 CSS 偽類時會發生什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

:hover:before text-decoration none has no effects?(:hover:before text-decoration none 沒有效果?)
Is CSS faster when you are specific?(當您特定時,CSS 會更快嗎?)
CSS sibling selectors (select all siblings)(CSS 兄弟選擇器(選擇所有兄弟))
IE: nth-child() using odd/even isn#39;t working(IE:使用奇數/偶數的 nth-child() 不起作用)
How can I tell if an element is in a shadow DOM?(如何判斷一個元素是否在影子 DOM 中?)
Can I use CSS to add a bullet point to any element?(我可以使用 CSS 為任何元素添加項目符號嗎?)
主站蜘蛛池模板: 日韩在线高清 | 亚洲欧洲日韩精品 中文字幕 | 一级全黄视频 | 久久久www成人免费精品张筱雨 | 国产午夜精品一区二区三区四区 | 一级黄色av电影 | 国产午夜精品一区二区三区 | 久久久精 | 亚洲福利在线视频 | 不卡av在线| 午夜精品福利视频 | 久久精品99国产精品 | 精品亚洲一区二区三区四区五区高 | 国产日韩欧美 | 久久国产精品一区二区三区 | 一级黄色短片 | 国产一区二区三区精品久久久 | 国产电影一区二区三区爱妃记 | 天天干b | 国产在线对白 | 久久久片 | 久久伊人精品 | 国产精品18久久久久久白浆动漫 | 国产精品福利一区二区三区 | 日本精品一区二区三区视频 | 欧美另类视频在线 | 亚洲精品电影在线观看 | 欧美日韩专区 | 久久久久久久国产 | 自拍偷拍一区二区三区 | 免费电影av | 欧美二区在线 | 久久国产精品网 | 18成人在线观看 | 国产精品免费在线 | 成人精品毛片国产亚洲av十九禁 | 亚洲成人一二三 | 中文字幕日韩在线观看 | av综合站| 亚洲国产精品一区二区久久 | 日一区二区 |