本文介紹了為什么我不應該在 CSS 中使用 ID 選擇器?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我對不要在 CSS 中使用 ID 選擇器"這一行感到震驚.這是真的嗎?我發(fā)現(xiàn)很多帖子都寫過這個.
I was shocked by this line "Don't use ID selectors in CSS". Is it true? I found many posts have written this.
- http://mattwilcox.net/archive/entry/id/1054/
- http://screwlewse.com/2010/07/dont-use-id-selectors-in-css/
- http://oli.jp/2011/ids/
我認為我們可以將 ID 用于選擇器.
I think we can use the ID for the selectors.
我還是想澄清一下.
推薦答案
Id 選擇器優(yōu)先于其他類型的選擇器.這會使使用不太具體的選擇器添加新規(guī)則變得更加困難,從而導致特異性戰(zhàn)爭:http://www.stuffandnonsense.co.uk/archives/css_specificity_wars.html
Id selectors have priority over other kinds of selectors. This can make it harder to add new rules using less specific selectors, leading to specificity wars: http://www.stuffandnonsense.co.uk/archives/css_specificity_wars.html
這篇關于為什么我不應該在 CSS 中使用 ID 選擇器?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!