本文介紹了CSS選擇器不是元素類型的孩子?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想為 a
標簽內的 code
元素設置樣式.
I want to style code
elements that are not inside a
tags.
實現這一目標的最佳方法是什么?
What is the best approach to accomplish this?
code:not(a code)
似乎根本不起作用,至少在 Chrome 上,即使它 似乎應該
code:not(a code)
doesn't seem to work at all, at least on Chrome, even though it seems like it should
我也無法通過控制臺運行它.
I can't get it to work from the console either.
還有其他我可以使用的純 css 方法嗎?
Are there any other css-only approaches I could use for this?
推薦答案
:not
不支持組合選擇器.
如果我們談論的是它的直接父母:
If we're talking about its direct parent:
:not(a) > code
否則在 CSS 中無法做到這一點.您必須覆蓋它:
Otherwise there's no way to do this in CSS. You'll have to override it:
code {
/* some styles */
}
a code {
/* override previous styles */
}
這篇關于CSS選擇器不是元素類型的孩子?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!