I’m attempting to vertically align text that has been rotated by -90deg and not having much luck. Code below
HTML:
<section class="page_block" style="background: <?php echo $background; ?>;">
<div class="row">
<div class="col-md-1">
<div id="header">
<h1 class="verticaltext">
<?php echo $page->post_title; ?>
</h1>
</div>
</div>
<div class="col-md-11">
<p><?php echo $page->post_content; ?></p>
</div>
</div>
</section>
CSS:
.page_block {
margin:0px;
padding:10px;
}
#header {
position: relative;
}
.verticaltext {
transform: rotate(-90deg);
transform-origin: right, top;
-ms-transform: rotate(-90deg);
-ms-transform-origin:right, top;
-webkit-transform: rotate(-90deg);
-webkit-transform-origin:right, top;
position: absolute; bottom: 0%; left: 0%;
color: #ed217c;
}
The result is like.
This is a WordPress theme, with Twitter Bootstrap implemented as well as a full width slider. I have confirmed that both Bootstrap and the Slider do not contain conflicting CSS.
Not sure why you had
bottom: 0%; left: 0%;
in the first place, but removing them results in your desired goal I believe.Here’s an example.
CSS:
HTML
CSS
Explanation
To achieve -90 deg text
writing-mode: vertical-lr
writes text vertically but is basically equivalent to rotating the text 90 degrees. Withtransform: rotate(180deg)
we end up with the -90 degrees look we want.To vertically align rotated text
I used
grid
andgrid-template-columns
to put the rotated text beside the div. This way the div can hold multiple lines or other things. Usetext-align
to align the rotated text however you want. In this case it’scenter
.note: You may not need:
grid-auto-rows: minmax(min-content, max-content)
. If the rotated text’s height does weird things, this can used to force wrap the rotated text to fit its content.There is a CSS property that rotates text and orients the containing blocks:
writing-mode
Here is a JS Fiddle example.
I’ve managed to achieve the same effect as Deruck but without changing the structure of the html.
JSFiddle
In the end, I’ve had to give up on the CSS front and generate the titles as transparent PNGs using GD. Not ideal, but gives me a lot more flexibility in terms of positioning. If anyone is interested in the rotation script I’m using, it’s below
Modified from Jason Lau’s awesome script, which can be found here.