这是我的 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)?
试试这个
<!DOCTYPE html>
<html>
<style>span {text-decoration: none;display: inline-block;}</style>
<body>
<a href="#">underscored text <span>without underscore</span></a>
</body></html>
设置它,使锚标记没有下划线,但跨度确实有下划线
<a href="#"><span>underscored text</span> without underscore</a>
a{
text-decoration:none;
}
a span{
text-decoration:underline;
}
我认为没有办法,所以这是一个肮脏的黑客:
<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。