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

CSS 特異性還是繼承?

CSS specificity or inheritance?(CSS 特異性還是繼承?)
本文介紹了CSS 特異性還是繼承?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我在這里查看過(guò)類似的問(wèn)題,但我沒(méi)有找到一個(gè)特別適合我的案例的問(wèn)題.

I've looked at similar questions here but I haven't found one particular to my case.

如果我正確閱讀了這篇文章:http://css-tricks.com/具體的css-specificity/

If I read this article correctly: http://css-tricks.com/specifics-on-css-specificity/

那么發(fā)生的事情對(duì)我來(lái)說(shuō)沒(méi)有意義.有人可以解釋這是由于地方,繼承還是特殊性嗎?我已經(jīng)刪除了所有不相關(guān)的 css.

then what is happening doesn't make sense to me. Can someone explain if this is due to locality, inheritance or specificity please? I've stripped out all the unrelated css.

CSS

a:link {font-size:0.875em;color:#005984}
.button {color:#fff}

HTML

<a class="button">Awesome call to action</a>

我最終得到了一個(gè)帶有藍(lán)色文本的按鈕,而不是白色.現(xiàn)在,a 是一個(gè)元素,所以它應(yīng)該比 .button 類具有更低的特異性,不是嗎?

I end up with a button that has blue text, instead of white. Now, a is an element, so it should have lower specificity than the .button class, should it not?

感謝您的寶貴時(shí)間.

推薦答案

這是由于 特異性:雖然 a 是一個(gè)元素類型選擇器,它沒(méi)有類選擇器那么具體,但它伴隨著一個(gè) :link 偽類,它同樣特定于您的 .button 類.因此,類型 + 偽類將比類更具體.

This is due to specificity: although a is an element type selector which is less specific than a class selector, it's accompanied by a :link pseudo-class which is equally specific to your .button class. A type + pseudo-class will therefore be more specific than a class.

這里沒(méi)有繼承,因?yàn)槲铱梢钥吹經(jīng)]有應(yīng)用于您的元素的父元素樣式.繼承是指采用父元素的樣式.當(dāng)您看到顯示藍(lán)色而不是白色的鏈接時(shí),這就是 cascade 在工作,而不是繼承.

There is no inheritance going on here as there are no parent element styles that I can see being applied to your element. Inheritance refers to adopting styles from parent elements. When you see the link displaying blue instead of white, that's the cascade at work, not inheritance.

Locality 不是 CSS 術(shù)語(yǔ)(至少不在其詞匯表中),所以我不確定您的意思.

Locality isn't a CSS term (at least not in its glossary), so I'm not sure what you mean by that.

如果你需要你的號(hào)召性用語(yǔ)按鈕是白色的,只需給它一個(gè) a 選擇器,這樣你的選擇器同樣具體,最后的聲明將優(yōu)先:

If you need your call-to-action button to be white, simply give it the a selector as well, so your selectors are equally specific and the last declaration will take precedence:

a:link {font-size:0.875em;color:#005984}
a.button {color:#fff}

這篇關(guān)于CSS 特異性還是繼承?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Style every third element?(每隔三個(gè)元素設(shè)置樣式?)
Why shouldn#39;t I use ID selectors in CSS?(為什么我不應(yīng)該在 CSS 中使用 ID 選擇器?)
What does img[class*=quot;alignquot;] mean in CSS?(CSS 中的 img[class*=“align] 是什么意思?)
CSS: Last element on line(CSS:最后一個(gè)元素)
How do I select every other div class element using just CSS (no js)(如何僅使用 CSS(無(wú) js)選擇所有其他 div 類元素)
Tool for checking unused CSS selectors?(檢查未使用的 CSS 選擇器的工具?)
主站蜘蛛池模板: 欧美一区二区三区视频 | 国产精品中文字幕在线 | 成人福利| 黄色片视频 | 黄色av网站在线观看 | 97国产爽爽爽久久久 | 一本久久a久久精品亚洲 | 精品精品视频 | a在线视频| 国产成人99久久亚洲综合精品 | 国产美女一区二区三区 | 午夜在线影院 | 中文字幕国产视频 | 羞羞午夜 | 国产乱码精品一区二区三区中文 | 久久国产精品一区 | 亚洲1区 | 国产一级免费在线观看 | 国产精品a久久久久 | 欧美日韩免费 | 国产一区二区三区久久久久久久久 | 亚洲一区中文字幕在线观看 | 人妖一区 | 天天躁日日躁狠狠的躁天龙影院 | 四虎在线观看 | 成人免费视频 | 特级做a爱片免费69 精品国产鲁一鲁一区二区张丽 | 久久国产精品一区二区三区 | 免费三级av| 好好的日在线视频 | 在线免费观看一区二区 | 欧美精品在线播放 | 日韩a在线观看 | 欧美一区二区三区日韩 | 午夜精品一区二区三区免费视频 | 国产日韩精品一区 | 午夜私人影院 | a在线视频观看 | 精品欧美一区二区三区久久久 | aa级毛片毛片免费观看久 | 日日干日日射 |