我在使用自定義字體(poppins-regular.ttf)時遇到問題。問題是當我爲span標籤設置背景色時,它是文本的包裝。如何解決在HTML中使用自定義字體的行高問題?
像g,y等等這樣的詞在底部被切掉了。但是,如果我將font-family從poppinsRegular更改爲tahoma,它看起來不錯。
但真正的問題是,我需要保持相同的行高
.passageBody, .passageBody2 {
width: 414px;
padding: 10px 0;
margin: 0px;
font-size: 24px;
line-height: 32px;
font-family: 'Poppins', sans-serif;
}
.passageBody2 {
font-family: tahoma;
}
.highlightPhrase {
background-color: yellow;
}
<link href="https://fonts.googleapis.com/css?family=Poppins" rel="stylesheet">
<div class="passageBody">
<span>「Good-bye to you and your funny feet.</span>
<span class="highlightPhrase">Thanks for all the eggs to eat!」 I was speaking to Bess, our chicken, and Mother laughed.</span>
</div>
<hr/>
<div class="passageBody2">
<span>「Good-bye to you and your funny feet.</span>
<span class="highlightPhrase">Thanks for all the eggs to eat!」 I was speaking to Bess, our chicken, and Mother laughed.</span>
</div>
我記得,行高並不需要像單位像素。只是把1.2 1.5或其他 – Obink
謝謝@obink,我給行高度1.3,它仍然顯示相同的問題 –
我認爲Poppins字體有設計行高的問題。我在我們的網站上使用這種字體,並且它不會完全顯示我正在更改行高。 – huykon225