【问题标题】:How to increase the space between the text and underline under a hyperlink in CSS? [duplicate]如何在 CSS 中增加超链接下的文本和下划线之间的间距? [复制]
【发布时间】:2021-12-10 06:55:42
【问题描述】:

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

期待一些答案。

【问题讨论】:

  • 不,您不能使用默认的 href。您可以自定义链接标签并根据需要使用它

标签: html css hyperlink underline line-spacing


【解决方案1】:

正如你在下面的sn-p中看到的,

我按照您的要求创建了一个自定义链接,请检查一下,如果您需要进一步的帮助,请告诉我。

.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>

【讨论】:

    猜你喜欢
    • 2010-12-16
    • 2020-09-18
    • 1970-01-01
    • 2013-12-01
    • 2021-04-12
    • 2019-09-15
    • 2015-10-13
    • 2017-11-24
    相关资源
    最近更新 更多