我有一些HTML锚链接代码,与文档的其余部分不同,我希望它看起来像是一个链接.
是否有一种简单的方法来禁用由于在锚标记中包装文本而导致的样式更改,而不必强制它是相同的(即,如果我更改正文字体样式,我不必更改其他一些:链接东西).
Jef*_*her 61
将颜色设置为黑色,将文本修饰设置为明确无颜色比为我工作更具侵略性.
我一直在寻找锚点的CSS是"良性",只是融入现有的CSS.这就是我的用途:
a.nostyle:link {
text-decoration: inherit;
color: inherit;
cursor: auto;
}
a.nostyle:visited {
text-decoration: inherit;
color: inherit;
cursor: auto;
}
Run Code Online (Sandbox Code Playgroud)
然后我只是将CSS nostyle类添加到我想要未格式化的锚点.
我通过创建一个类.reset-a
并针对它的所有伪类来实现这一点。
以所有伪类为目标对于使其完美无缺非常重要。
outline: 0
当链接处于焦点或活动状态时,该属性会移除链接周围的虚线边框。
.reset-a, .reset-a:hover, .reset-a:visited, .reset-a:focus, .reset-a:active {
text-decoration: none;
color: inherit;
outline: 0;
cursor: auto;
}
Run Code Online (Sandbox Code Playgroud)
如果您不关心IE,则可以将链接样式附加到链接样式中(相关链接的ID :not(#exclude)
在哪里exclude
):
a:link:not(#exclude), a:visited:not(#exclude) {
text-decoration: none;
color: blue;
cursor: pointer;
}
Run Code Online (Sandbox Code Playgroud)
否则,我认为您无法按照自己的描述进行暴力破解。您可以改用内联样式(不推荐),也可以使用分配给该链接的特殊类/ ID,将其与选择器分组body
。例如,如果您具有以下样式:
body {
text-decoration: none;
color: black;
cursor: auto;
}
a:link, a:visited {
text-decoration: none;
color: blue;
cursor: pointer;
}
Run Code Online (Sandbox Code Playgroud)
您可以简单地将一个更具体的选择器(与该链接匹配)扔到body
规则上:
body, #exclude {
text-decoration: none;
color: black;
cursor: auto;
}
a:link, a:visited {
text-decoration: none;
color: blue;
cursor: pointer;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
30332 次 |
最近记录: |