Html 如何在没有文本装饰的情况下在文本下方划一条线:下划线?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35285467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 18:55:37  来源:igfitidea点击:

How to make a line below text without text-decoration: underline?

htmlcss

提问by Lakshminarayanan

I need to add a line below the text, without text-decoration: underline;otherwise how to make a custom space between text and line.

我需要在文本下方添加一行,没有文本装饰:下划线;否则如何在文本和行之间创建自定义空间。

What we do

我们所做的

回答by Pedram

You can use Border-Bottomwith some Padding-Bottom.

您可以Border-Bottom与一些Padding-Bottom.

a {
border-bottom: 1px solid black;
padding-bottom: 5px;
}
<a>Example Text</a>

Also you can use pseudo element, use after or before to add a line under the text or anything else.

您也可以使用伪元素,使用 after 或 before 在文本或其他任何内容下添加一行。

a::after {
 display: block;
   content: '';
  width: 100%;
  height: 1px;
  background: black;
  position: absolute;
  bottom: 0;
  left: 0;
}

a {
position: relative;  
}
<a>Example Text</a>

回答by Manwal

border-bottom:

边框底部

span{
  border-bottom:1px solid #000;
}
<span>What we do</span>