One way to align skewed text in a vertical line is to manually set a negative text-indent . This method also requires you to set transform-origin in the lower left of the screen:
.skew-parent-wrapper { width: 300px; margin-left: 100px; margin-top: 50px; border: 1px solid red; padding-top: 30px; } .skew-text { transform: rotate(-10deg) skew(-30deg, 0deg); transform-origin: 0 100%; text-indent: -15px; }
<div class="skew-parent-wrapper"> <h1 class="skew-text">Hello Welcome to the skew text</h1> </div>
This method works with text that wraps on only two lines. For text with more than two lines, you need to wrap each line in the tag (for example, <<22>):
.skew-parent-wrapper { width: 300px; margin-left: 100px; margin-top: 50px; border: 1px solid red; padding-top: 30px; } .skew-text span{ display:block; transform: rotate(-10deg) skew(-30deg, 0deg); transform-origin: 0 100%; }
<div class="skew-parent-wrapper"> <h1 class="skew-text"> <span>Hello Welcome to the</span> <span>skewed text with</span> <span>several lines many</span> <span>many many lines</span> </h1> </div>
Note that you need to set the <span> to display:block , because the transformations do not apply to inline elements .
source share