提问者:小点点

我的h1元素的文本比元素的实际高度短。我能把空的地方移走吗?[副本]


我有一个具有以下类的

元素:

null

.product-name {
  font-size: 36px;
  font-weight: 600;
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 20px;
  margin-bottom: 20px;
}
<h1 class="product-name">My awesome product </h1>

null

文本呈现如下所示:

正如您所看到的,文本上下都有一些空白。我正努力做到这一点:

那能实现吗?


共2个答案

匿名用户

我想你是说这个。我添加了行高:1;

null

.product-name {
    font-size: 36px;
    font-weight: 600;
    border-bottom: 1px solid #dee2e6;
    line-height: 1;
    margin-bottom: 20px;
    display: inline-block;
}
<h1 class="product-name">Aadaadf</h1>

匿名用户

null

.product-name {
  font-size: 36px;
  font-weight: 600;
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 20px;
  margin-bottom: 20px;
  line-height: 30px; /* here */
}
<h1 class="product-name">My awesome product </h1>