4

这是我的 HTML:

<!DOCTYPE html>
<html>
<style>span {text-decoration: none}</style>
<body>
<a href="#">underscored text <span>without underscore</span></a>
</body></html>

<span>遗骸强调了这一点。什么是可能的解决方法(不使用 JavaScript 且不更改 HTML)?

4

3 回答 3

4

试试这个

<!DOCTYPE html>
<html>
<style>span {text-decoration: none;display: inline-block;}</style>
<body>
<a href="#">underscored text <span>without underscore</span></a>
</body></html>​

链接到原始答案:https ://stackoverflow.com/a/10478962/662250

工作小提琴

于 2012-11-18T17:38:07.700 回答
1

设置它,使锚标记没有下划线,但跨度确实有下划线

<a href="#"><span>underscored text</span> without underscore</a>

a{
  text-decoration:none;
}

a span{
  text-decoration:underline;
}
于 2012-11-18T17:31:29.673 回答
0

我认为没有办法,所以这是一个肮脏的黑客:

<html>
<style>
    span {border-bottom:1px solid white;}
    a {text-decoration: none;border-bottom:1px solid blue;}
    </style>
<body>
<a href="#">underscored text <span>without underscore</span></a>
</body></html>​

...仅因为您提到您无法更改 HTML。

于 2012-11-18T17:41:23.350 回答