gpt4 book ai didi

html - css:如何在不增加整个文本行高的情况下增加一个字符的字体大小?

转载 作者:太空宇宙 更新时间:2023-11-04 00:50:16 26 4
gpt4 key购买 nike

我有一个来自其他 font-family 的符号,需要调整它的大小。不幸的是 font-size:200% 增加了整行的行高;

如何在不增加行高的情况下增加一个字符font-size

我知道如何使用 position:absolute 来“切断”字符,但这也会水平移动文本。当我想要的是 line-height: inherit 行时(这是行不通的)。

.increased {
font-size:200%
}
<p>normal</p>
<div style="background-color:yellow">.text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text </div>
<p>increased (problematic)</p>
<div style="background-color:yellow"> <span class="increased">.</span>text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text </div>

最佳答案

如果您确定它不会是该行中的唯一字符,您可以使用 line-height: 0。否则,您将不得不手动调整 line-height 值。

.increased {
font-size: 200%;
line-height: 0
}
<p>normal</p>
<div style="background-color:yellow">.text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text </div>
<p>increased (problematic)</p>
<div style="background-color:yellow"> <span class="increased">.</span>text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text </div>

关于html - css:如何在不增加整个文本行高的情况下增加一个字符的字体大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56093941/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com