Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stretching text horizontally using CSS

Tags:

html

text

css

I am required to stretch text horizontally, but the only thing I could find was font-stretch which, according to w3schools, isn't supported by any browser.

Is there any other way which I can meet this effect?

like image 888
JBrookes Avatar asked Apr 08 '13 12:04

JBrookes


People also ask

How do I stretch text height in CSS?

use CSS transform:scaleY(yValue) to stretch it vertically, on the Y axis. This might pixelate the text in some browsers. An alternative is to use SVG text, then apply transform="scale(0, yValue)" attribute, which will not pixelate (it's a vector!).


1 Answers

Yes - you can achieve this by using CSS 2D transforms.

Here's a working JSFiddle.

Note that 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!

HTML:

<span>Hello!</span>

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.

like image 170
dsgriffin Avatar answered Sep 24 '22 15:09

dsgriffin