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

标签 html css css-position

我有一个来自其他 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/

相关文章:

html - 在 URL 中强制换行

javascript - 固定标题视差滚动

css - 网页游戏的定位和边距

CSS 相对定位+浏览器兼容性

javascript - 多段随机颜色功能

html - 在不失去响应能力的情况下删除子主题中的 CSS 参数

javascript - 使用chance.js将随机单词放入html中

css - child 的边距和 parent 的边界

javascript - 为什么我使用 css 时我的页面没有加载?

css - 叠加多个div图片