简体   繁体   English

选择所有没有h标签的链接

[英]Select all a links without h tags

I want to underline all links but not if the links are h1,h2 and so on. 我想强调所有链接,但不是链接是h1,h2等等。 here is a simple css: 这是一个简单的CSS:

#heatmapthemead-the-content-container .entry-content a {
    text-decoration: underline;
}

This underlines all links including h1,h2,h3 when I use :not selector it doesn't work and also h1,h2 stay underlined 当我使用时,这会强调包括h1,h2,h3在内的所有链接:不是选择器它不起作用而且h1,h2保持下划线

#heatmapthemead-the-content-container .entry-content a:not(h1,h2,h3) {
        text-decoration: none;
    }

I use also !important : 我也用!重要的是:

h1,h2,h3,h4,h5,h6 a {
text-decoration: none !important;
}

But h1,h2 links stay underlined. 但是h1,h2链接仍然有下划线。 Does anybody have a trick? 有人有诀窍吗?

There's no need to make it !important . 没有必要成功!important Look at the example below. 看下面的例子。

 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> 

You're writing the code in wrong way, write it like 你是以错误的方式编写代码,写得像

h1 a, h2 a, h3 a{
    text-decoration: none;
}

and so on. 等等。

And writing like this will make the code more readable, and easier to find your mistake. 像这样编写会使代码更具可读性,更容易找到错误。

h1 a,
h2 a,
h3 a{
    text-decoration: none;
}

It not gonna make any difference in the output though. 但它不会对输出产生任何影响。

Your last example has the right idea and should work if you did it like this: 你的最后一个例子有正确的想法,如果你这样做,它应该工作:

h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
    text-decoration: none !important;
}

You don't have to use :not . 你不必使用:not All you have to do is select the tags but add a next to it, so that it selects the h1s that are a link. 您所要做的就是选择标签,但在其旁边添加一个标签,以便选择作为链接的h1。 By doing the following it should work. 通过执行以下操作它应该工作。

h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
    text-decoration: none !important;
}

To see more click here 要查看更多,请单击此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM