I have a div with a heading inside it that has been transformed with CSS to be rotated -90 degrees so it appears vertically.
#mydiv h2 {
writing-mode: tb-rl;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
filter: progid: DXImageTransform.Microsoft.BasicImage(rotation=3);
white-space: nowrap;
width: 20px;
height: 20px;
}
The problem is that the containing div doesn’t stretch with the text; instead, the text floats outside the div box.
How can I make the div stretch with the text?
Try setting
width: auto;andtransform-origin, but on the containingdiv– like this:You can see it in action here: http://dabblet.com/gist/2725392
Hope this helps!