how to change glyph height without changing the font-size?

允我心安 提交于 2019-12-22 03:43:41

问题


Issue

for text elements that are adjacent to icon elements, the glyph height is not aligned with the icon height. the text elements are styled by CSS with font-size: 20px; and have consistent width for all their instances.

here's an illustration:

for the above case, the text should have the same height as the icon.

Motivation

finding a way to make the letters a bit taller to take up the available vertical space, while keeping the font-size as is. how to do that?

What have I tried?

to increase the font-size a bit, but came to conclusion i'll have to compromise for a smaller icon if I can't increase the letter height, thus the issue.


回答1:


You can do it with css3 property Scale: (demo on dabblet.com)

HTML markup:

<span class="lower">lower size</span>
<span>normal size</span>
<span class="taller">taller size</span>

CSS:

span {
    font-size: 20px;
    display: inline-block;
}

span.lower{ transform: scaleY(0.9); }
span.taller { transform: scaleY(1.1); }

Also, you can try to set various values of vertical-align for images in your case: sub, super, bottom, top, middle. This may help to solve your problem from another point.




回答2:


Try adding line-height: 20px; it will only increase the space between lines. It should help you match the element height.

And considering your calendar icon and text, add vertical-align: middle; to the image.

Demo: http://jsfiddle.net/rBpKL/3/




回答3:


No, you cannot make letters taller without increasing font size—or changing font. In principle, you can decrease letter spacing, so that you could increase font size without increasing the width of the text. This is usually a bad idea, since it tends to make the font look worse and often less legible.

Showing the real problem in context (code or URL) might help to find a solution.



来源:https://stackoverflow.com/questions/11010457/how-to-change-glyph-height-without-changing-the-font-size

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!