css屬性選擇器 疑惑
<style>
????.columnNews{background:red}
</style>???
<style>
????a[style='background:red']{
???????color:red;
????}
</style>↑↑↑↑↑ 為什么這樣,不起作用.
<style>
????a[style='background:red']{
???????color:red;
????}
</style>
...
<a?href="##"?class="columnNews"?style='background:red'>我的背景想變成紅色</a>
...↑↑↑↑↑ 但這樣,卻可以.
是因為屬性選擇器只支持行內樣式?還是我的我獲取內嵌樣式的方法不對?
2017-09-27
你的第一種寫法
<style>
????a[style='background:red']{
???????color:red;
????}
</style>
這個a[style='background:red']這條屬性在a標簽內部是找不到的,即對a進行檢索的時候,匹配不到style='background:red'這串字段,所以無法執行a[style='background:red']{color:red}這行代碼。
2017-02-27
是網頁樣式的識別先后順序的問題,內嵌樣式 >> 頁內標簽樣式 >> 外鏈樣式表樣式|
還有一個是遍歷的問題,在同一級別,有重復的樣式屬性,后面的樣式會覆蓋掉前面的樣式。