久久久久久久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 選擇器的工具?)
主站蜘蛛池模板: 国产精品成人一区二区三区 | 在线播放第一页 | 一区二区精品 | 成在线人视频免费视频 | 国产在线高清 | 成人天堂噜噜噜 | 欧美成视频 | 91精品福利 | 一区二区三区四区在线 | 中文字幕免费在线 | 天堂网中文字幕在线观看 | 国产在线观看一区二区三区 | 91在线精品一区二区 | 中文字幕视频在线 | 成人免费视频网站在线观看 | 欧美福利在线 | 久久激情视频 | 四虎永久| 亚洲视频 欧美视频 | 超碰免费在线观看 | 日本激情一区二区 | 成人一区二区三区 | 国产不卡在线 | 日日操夜夜操天天操 | 搞黄网站在线观看 | 午夜视频免费在线观看 | 涩涩视频网站在线观看 | 中文字幕高清免费日韩视频在线 | 日韩三级在线 | 精品国产一区二区三区久久 | 国产激情毛片 | 欧美精品二区 | 色综合久久久 | 亚洲欧美精品在线 | 亚洲三区在线观看 | 国产欧美日韩综合精品一区二区 | 一区二区三区四区日韩 | 午夜视频在线免费观看 | 国产亚洲欧美另类一区二区三区 | 久久伊人精品 | av资源网站|