简体   繁体   English

使用CSS拉伸字体的最实用方法

[英]The most practical way to stretch fonts using css

I want to stretch the Helvetica font making the text 20% taller, I've looked around and can see theres nothing that has all browser support without using some kind of JS or hacks. 我想拉伸Helvetica字体,使文本高20%,我环顾四周,发现没有使用某种JS或hacks的浏览器就无法支持所有功能。

What would be the most practical way to do this using (preferably) just CSS? 使用CSS(最好是仅使用CSS)最可行的方法是什么? My initial thought would be to find a similar taller font and use that instead. 我最初的想法是找到一个类似的较高字体并使用它。

Kind of a hack, not very cross-browser, and may not work for your situation, but despite that you could use transform: scale(1,1.5); 有点像黑客,不是跨浏览器,可能无法满足您的情况,但是尽管如此,您可以使用transform: scale(1,1.5); .

.tallhelvetica{
    font:20px Helvetica;
    transform: scale(1,1.5);
}

Other than that, you would need to find or create another font. 除此之外,您将需要查找或创建其他字体。

See this demo: JSFiddle . 观看此演示: JSFiddle

There is no way to strech a font vertically in CSS. 在CSS中无法垂直拉伸字体。 What @SuperScript's answer demonstrates means stretching any content vertically in an algorithmic way. @SuperScript的答案表明,它意味着以算法方式垂直扩展任何内容。 It means that horizontal strokes are thickened, among other things, and the result is typographically inferior. 这意味着除其他因素外,水平笔划被加粗,并且印刷效果较差。

The font-stretch property carries a misleading name: it is meant to select a typeface (specific font in a font family) based on its design in the horizontal direction – it does not stretch a font but selects a “stretched” or “condensed” typeface. font-stretch属性带有一个误导性的名称:它是根据水平方向的设计来选择字体(字体系列中的特定字体)–它不会拉伸字体,而是选择“拉伸”或“压缩”字体。 Most fonts commonly used on web pages do not have such typefaces. 网页上常用的大多数字体都没有这种字体。 And in any case that would not have anything to do with vertical stretching in any sense. 而且在任何情况下都与垂直拉伸没有任何关系。

The conclusion is indeed that you should find a different font – or reconsider the decision that made you think you need a taller font. 结论确实是您应该找到其他字体–或重新考虑使您认为需要更高字体的决定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM