[英]Select all a links without h tags
我想強調所有鏈接,但不是鏈接是h1,h2等等。 這是一個簡單的CSS:
#heatmapthemead-the-content-container .entry-content a {
text-decoration: underline;
}
當我使用時,這會強調包括h1,h2,h3在內的所有鏈接:不是選擇器它不起作用而且h1,h2保持下划線
#heatmapthemead-the-content-container .entry-content a:not(h1,h2,h3) {
text-decoration: none;
}
我也用!重要的是:
h1,h2,h3,h4,h5,h6 a {
text-decoration: none !important;
}
但是h1,h2鏈接仍然有下划線。 有人有訣竅嗎?
沒有必要成功!important
。 看下面的例子。
a{ text-decoration: underline; } h1 a, h2 a, h3 a{ text-decoration: none; }
<div> <h1><a href="#">Sample</a></h1> <p><a href="#">Sample</a></p> <h2><a href="#">Sample</a></h2> <div><a href="#">Sample</a></div> <h3><a href="#">Sample</a></h3> </div>
你是以錯誤的方式編寫代碼,寫得像
h1 a, h2 a, h3 a{
text-decoration: none;
}
等等。
像這樣編寫會使代碼更具可讀性,更容易找到錯誤。
h1 a,
h2 a,
h3 a{
text-decoration: none;
}
但它不會對輸出產生任何影響。
你的最后一個例子有正確的想法,如果你這樣做,它應該工作:
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
text-decoration: none !important;
}
你不必使用:not
。 您所要做的就是選擇標簽,但在其旁邊添加一個標簽,以便選擇作為鏈接的h1。 通過執行以下操作它應該工作。
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
text-decoration: none !important;
}
要查看更多,請單擊此處
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.