Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

90 degrees rotated text, flush to page top-right with CSS

I know how to rotate text 90 degrees using CSS, but I'm trying to align the text to the top-right of the page (or a parent element) as its 90-degree-rotated self. Is this possible?

Example:

enter image description here

like image 646
Dan Avatar asked Aug 22 '13 23:08

Dan


1 Answers

Neither of the previous solutions work for any amount of text. You need to use transform-origin.

<div class="container">
<span class="rotate">Hello THERE!</span>
</div>

.rotate {

    -webkit-transform: rotate(90deg);
    -webkit-transform-origin: left top;
    -moz-transform: rotate(90deg);
    -moz-transform-origin: left top;
    -ms-transform: rotate(90deg);
    -ms-transform-origin: left top;
    -o-transform: rotate(90deg);
    -o-transform-origin: left top;
    transform: rotate(90deg);
    transform-origin: left top;

    position: absolute;
    top: 0;
    left: 100%;
    white-space: nowrap;    
    font-size: 48px;
}
like image 191
meub Avatar answered Oct 27 '22 00:10

meub