僅使用 CSS 定位 Firefox - Targeting only Firefox with CSS

問題:

Using conditional comments it is easy to target Internet Explorer with browser-specific CSS rules:使用條件註釋可以很容易地使用特定於瀏覽器的 CSS 規則來定位 Internet Explorer:

<!--[if IE 6]>
...include IE6-specific stylesheet here...
<![endif]-->

Sometimes it is the Gecko engine (Firefox) that misbehaves.有時是 Gecko 引擎 (Firefox) 出現問題。 What would be best way to target only Firefox with your CSS rules and not a single other browser?使用 CSS 規則僅針對 Firefox 而不是其他瀏覽器的最佳方法是什麼? That is, not only should Internet Explorer ignore the Firefox-only rules, but also WebKit and Opera should.也就是說,不僅 Internet Explorer 應該忽略 Firefox-only 規則,WebKit 和 Opera 也應該忽略。

Note: I'm looking for a 'clean' solution.注意:我正在尋找一個“乾淨”的解決方案。 Using a JavaScript browser sniffer to add a 'firefox' class to my HTML does not qualify as clean in my opinion.在我看來,使用 JavaScript 瀏覽器嗅探器將“firefox”類添加到我的 HTML 並不符合標準。 I would rather like to see something that depends on browser capabilities, much like conditional comments are only 'special' to IE…我寧願看到一些依賴於瀏覽器功能的東西,就像條件註釋對 IE 來說只是“特殊”的一樣……


解決方案:

參考一: https://en.stackoom.com/question/3zsj
參考二: https://stackoom.com/question/3zsj
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章