我已經有這個代碼在我的style.css(使用WordPress):我如何重寫錨標籤屬性?
a:link, a:visited {
color: #3088FF;
text-decoration: none;
}
我想改變錨文本的顏色,字體樣式,大膽等進行分類。我怎樣才能覆蓋這個?
我已經有這個代碼在我的style.css(使用WordPress):我如何重寫錨標籤屬性?
a:link, a:visited {
color: #3088FF;
text-decoration: none;
}
我想改變錨文本的顏色,字體樣式,大膽等進行分類。我怎樣才能覆蓋這個?
假設你的意思是錨具有內嵌樣式已經是你想用CSS來覆蓋,使用!important
關鍵字:
<a href="#" style="color: red;">hello</a>
CSS:
a:link, a:visited {
color: #3088FF !important;
text-decoration: none;
}
這將覆蓋所有其他風格,包括內嵌式的,如果你是擔心跨瀏覽器兼容,那麼你不應該:What browsers support "!important"?
HI, BUT I just wanna apply this anchor text CSS only to that particular anchors, my override CSS shouldnt change actual behavior of CSS.. So, does this !important; can only be used for specific anchor tags..? –
@Lisa for this you will have to add 'class="something"' to the anchors you want and have '.something { color: #3088FF !important; }' –
如果您必須覆蓋現有樣式,使用!important
聲明。例如,
.myStyledLink{
color: #FFF !important;
}
HI, BUT I just wanna apply this anchor text CSS only to that particular anchors, my override CSS shouldnt change actual behavior of CSS.. So, does this !important; can only be used for specific anchor tags..? –
You can use a class on the anchors which you want to override the css rules. 'MyLinkText' – looq
確定輸出HTML中類別小部件的ID。假設id="widget-cat"
,然後按如下所示創建CSS規則以覆蓋該窗口小部件中的鏈接顏色,例如,
#widget-cat a:link, #widget-cat a:visited {
color: #FFF;
}
使用的!important
是很不得已壓倒一切的風格真的,我建議只使用過,如果你需要覆蓋不能作出更加具體,由第三方寫CSS規則那些你無法控制的開發者。
您的意思是錨點有內聯樣式(例如'') which you want to override with CSS? –
HI, this anchor CSS just need to change to some specific widget, thats all, BUT it shouldnt change over all CSS... –