EDIT: Another way is shown below the first snippet
probably css transforms would be enough for this situation.
rotate(-90deg);
will rotate the text
translateX(-100%)
will fix the position (which originally would overflow on the top of the container
transform-origin: 0 0;
tells the browser to apply those transformations from the top-left corner.
Here it is how it looks. Be aware that handling overflows is not easy if you use css transforms.
html, body{
height:100%;
}
.a{
height:100%;
font-size:40px;
background-color:#cccccc;
display:inline-block;
}
.rotated {
transform: rotate(-90deg) translateX(-100%);
transform-origin: 0 0;
display: inline-block;
max-width: 100vh;
}
<div class="a">
<span class="rotated">
HELLO WORLD!
</span>
</div>
A different way to do this, would be to use the css property "writing-mode". This should be the best solution to create vertical text, but it will only let you write from top to bottom, and not from bottom to top. To circumvent this problem, we could flip the element both vertically and horizontally using transform: scale(-1)
or scale: -1
. This solution might be a better fit in situations that would be complicated because of the text overflow (but it will create weird effects if you try to select the text).
html, body{
height:100%;
}
.a{
height:100%;
font-size:40px;
background-color:#cccccc;
display:inline-block;
}
.rotated {
writing-mode: vertical-rl;
scale: -1;
}
<div class="a">
<span class="rotated">
HELLO WORLD!
</span>
</div>