当鼠标悬停在链接上时我想显示虚线,这种方法不起作用。
.text-link {
color: #446CB3;
font-family: "Tahoma";
font-size: 15px;
text-decoration:none;
}
.text-link:hover {
text-decoration-style: dotted;
}

<a href="URL" target="_blank" data-role="none">
<span class="text-link">Click me</span>
</a>
&#13;
答案 0 :(得分:4)
看起来text-decoration-style: dotted
不是supported in all browsers:
要获得完全支持,您可以使用border-bottom-style: dotted
。
为了使其正常工作,您需要使用text-decoration: none
从锚元素中删除下划线。然后只需在元素中添加border-bottom
:
a {
text-decoration: none;
}
.text-link {
color:#446CB3;
font-family:"Tahoma";
font-size:15px;
border-bottom: 1px solid;
}
.text-link:hover {
border-bottom-style: dotted;
}
<a href="URL" target="_blank" data-role="none"><span class="text-link">Click me</span></a>
答案 1 :(得分:2)
试试这个。
HTML:
<a href="URL" target="_blank" data-role="none"><span class="text-link">Click me</span></a>
CSS:
.text-link{
color:#446CB3;
font-family: "Tahoma";
font-size:15px;
text-decoration: none;
}
.text-link:hover{
border-bottom: 2px dotted #446CB3;
}
答案 2 :(得分:1)
您使用的浏览器是什么? text-decoration-style
只有Firefox根据W3Schools支持,如果您关闭text-decoration-style
,则悬停正常。见this fiddle。
答案 3 :(得分:1)
只有firefox支持,它需要-moz-
前缀。
https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-style
它也应该应用于a
(或从a
中移除它并在text-decoration
上应用完整的span
(< / p>
a {
color: #446CB3;
font-family: "Tahoma";
font-size: 15px;
}
a:hover {
-moz-text-decoration-style: dotted;
}
&#13;
<a href="URL" target="_blank" data-role="none">
<span class="text-link">Click me</span>
</a>
&#13;
答案 4 :(得分:1)
text-decoration-style
仅受Firefox 36支持(在撰写本文时尚未在稳定分支上发布)。
对于早期版本的Firefox,您可以使用该属性的-moz-
前缀版本。在其他浏览器中,您只能使用边框伪装它。
答案 5 :(得分:0)
您还应该设置text-decoration-line
,也可以设置text-decoration-color
。
另请考虑使用text-decoration
速记属性:
.text-link:hover {
text-decoration: underline dotted;
}
.text-link {
color: #446CB3;
font-family: "Tahoma";
font-size: 15px;
}
.text-link:hover {
text-decoration: underline dotted;
}
<a href="URL" target="_blank" data-role="none">
<span class="text-link">Click me</span>
</a>
但是,你仍然会有锚text-decoration
。为了防止主播text-decoration
影响.text-link
(但不能影响主播中的其他内容),您可以使用
.text-link {
display: inline-block;
}
.text-link {
color: #446CB3;
font-family: "Tahoma";
font-size: 15px;
}
.text-link {
display: inline-block;
}
.text-link:hover {
text-decoration: underline dotted;
}
<a href="URL" target="_blank" data-role="none">
<span class="text-link">Click me</span>
</a>
答案 6 :(得分:0)
.text-link {
color: #446CB3;
font-family: "Tahoma";
font-size: 15px;
text-decoration:none;
}
.text-link:hover {
text-decoration:underline;
text-decoration-style: dotted;
}
<a href="URL" target="_blank" data-role="none" >
<span class="text-link">Click me</span>
</a>
.text-link {
color: #446CB3;
font-family: "Tahoma";
font-size: 15px;
text-decoration:none;
}
.text-link:hover {
text-decoration:underline;
text-decoration-style: dotted;
}
<a href="URL" target="_blank" data-role="none" class="text-link">
<span>Click me</span>
</a>