如何在CSS超链接下增加文本和下划线之间的空间?



对于任何文本和下划线,我们可以使用line-height和padding-bottom。但在我的情况下,我已经使用了超链接,所以当我悬停在超链接,我希望文本装饰下划线,以增加超链接文本和下划线之间的间距?

期待答案

从下面的代码片段中可以看到,

我用你正在寻找的方式创建了一个自定义链接,如果你需要进一步的帮助,请查看并告诉我。

.custom {
text-decoration: none;
display: inline-block;
position: relative;
}
.custom::after {
content: '';
display: inline-block;
width: 100%;
left: 0;
height: 1px;
position:absolute;
background-color: rgb(0, 0, 238);
bottom: -2px;
}
<h2>Normal Link</h2>
<a href="google.com">Hello</a>
<h2>Custom Link</h2>
<a href="google.com" class='custom'>Hello</a>

最新更新