我正在尝试创建一个页面,其中有锚链接,并且所有链接都是通向相同页面但位于其上的不同位置的锚。链接应始终具有“虚线”风格并且永远不要加下划线。如下图所示始终有虚线样式的链接
a:hover, a:link, a:active .link-anchor {
border-bottom: 1px dashed #aabbccdd ;
text-decoration: dashed !important;
}
我正在尝试创建一个页面,其中有锚链接,并且所有链接都是通向相同页面但位于其上的不同位置的锚。链接应始终具有“虚线”风格并且永远不要加下划线。如下图所示始终有虚线样式的链接
a:hover, a:link, a:active .link-anchor {
border-bottom: 1px dashed #aabbccdd ;
text-decoration: dashed !important;
}
您已经定义无效颜色代码:这不上班untented
border-bottom: 1px dashed #aabbccdd;
// ^^^ there should be 3 or 6 characters
它应该是:
border-bottom: 1px dashed #aabbcc;
有关CSS的颜色更多信息,访问Here。
a.link-anchor:hover, a.link-anchor:link, a.link-anchor:active {
border-bottom: 1px dashed #aabbcc;
text-decoration: none;
}
<p>Lorem ipsum dolor <a href="#" class="link-anchor">Dashed Link</a> sit amet <a href="#">Normal Link</a> Lorem ipsum dolor <a href="#" class="link-anchor">Dashed Link</a> sit amet <a href="#" class="link-anchor">Dashed Link</a> Lorem ipsum dolor</p>
我该如何让'a:hover,a:link,a:active'只应用于类'.link-anchor'的链接,而不会影响其他链接? – Johshi
将您的选择器更改为'a.link-anchor:hover,a.link-anchor:link,a.link-anchor:active'。我也会在我的回答中更新。 –
除了什么穆罕默德说,我认为,规则也有错
如果你想添加的类别,你应该重复.link-anchor
a.link-anchor:hover, a.link-anchor:link, a.link-anchor:active {
或
a:hover, a:link, a:active, .link-anchor {
另外,如果你的类做“边框虚线下方”不称之为“链接锚”,而是“虚下划线”,例如
请提供更多的代码或的jsfiddle –
@SyamPillai,为什么呢? – Johshi