如何防止行高在顶部添加边距? [英] How to prevent line-height from adding a margin in the top?
问题描述
每当我使用大于的line-height
,例如 1.6em
,它总会在我不想要的文字。
Whenever i use a large line-height
like 1.6em
it always adds a margin in the very top of the text which i don't want.
示例: http://jsfiddle.net/EstpJ/1/
我希望文字内容清晰,边框清晰,没有任何顶部或
i want the text to be sharply lined with the borders and not have any kind of top or bottom margin.
如何解决这个问题?
推荐答案
什么 line-height
是,它是一个手动方式设置一行文本的高度,以便包装文本等。实际可见的大小由 font-size
以及 font-family
更小的延伸决定。正常文本/字体的平均 line-height
大约是 1.2em
。任何大于此值的内容都会导致显示信箱,这正是您的描述。使用较小的值将导致连续的线彼此重叠。
That's exactly what line-height
is, it's a manual way to set the height of a line of text for the purposes of wrapping text and such. The actual visible size is determined by the font-size
and to a lesser extend by the font-family
. The average line-height
for normal text/font is around 1.2em
. Anything larger than that will cause visible letterboxing, which is exactly what you are describing. Using a smaller value will cause successive lines to overlap each other.
修复您的示例的唯一方法是引入更多的标记来确定行号,以便您可以第一行/最后一行不同。
The only way to fix your exact example is introduce more markup to determine line numbers so that you can style the first/last line differently.
这篇关于如何防止行高在顶部添加边距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!