Html 使用 CSS 水平拉伸文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15878971/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Stretching text horizontally using CSS
提问by JBrookes
I am required to stretch text horizontally, but the only thing I could find was font-stretchwhich, according to w3schools, isn't supported by any browser.
我需要水平拉伸文本,但我唯一能找到的是font-stretch,根据 w3schools 的说法,任何浏览器都不支持它。
Is there any other way which I can meet this effect?
有没有其他方法可以达到这种效果?
回答by dsgriffin
Yes- you can achieve this by using CSS 2D transforms.
是的- 您可以通过使用CSS 2D 转换来实现这一点。
Here's a working jsFiddle.
这是一个有效的jsFiddle。
Notethat the example in the fiddle/code below is for Chrome/Safari (webkit), however, you can use 2D transforms in all major browsers by using the -moz-
, -o-
, and ms
equivalent prefixes/methods!
请注意,下面的小提琴/代码的例子是针对Chrome / Safari浏览器(WebKit的),但是,您可以通过使用使用所有主流浏览器的2D变换-moz-
,-o-
以及ms
等同前缀/方法!
HTML:
HTML:
<span>Hello!</span>
CSS:
CSS:
span {
transform:scale(3,1);
-webkit-transform:scale(3,1);
display:inline-block;
}
Support:
支持:
It is supported in Chrome, Firefox, IE9+ and Opera browsers.
它在 Chrome、Firefox、IE9+ 和 Opera 浏览器中受支持。
回答by Andrea Turri
Do you mean this? With CSS:
你是这个意思吗?使用 CSS:
text-align: justify