I can't seem to align a vertically rotated div all the way to the right side of the page: http://jsfiddle.net/F23W2/2/
HTML:
<div class="vertical">Vertical Text</div>
CSS:
.vertical {
    position: relative;
    background-color: #DDDDDD;
    padding: 10px;
    border-radius: 5px 5px 0 0;
    float: right;
    -moz-transform: rotate(270deg);  /* FF3.5+ */
    -o-transform: rotate(270deg);  /* Opera 10.5 */
    -webkit-transform: rotate(-90deg);  /* Saf3.1+, Chrome */
} 
Although I can use negative margins to work around, I was wondering if a cleaner solution exists.
Use the CSS line-height property Add the line-height property to the element containing a text larger than its font size. By default, equal spaces will be added above and below the text, and you'll get a vertically centered text.
The vertical-align property in CSS controls how elements set next to each other on a line are lined up. In order for this to work, the elements need to be set along a baseline. As in, inline (e.g. <span> , <img> ) or inline-block (e.g. as set by the display property) elements.
Change the origin of the rotation transform via transform-origin: 100% 100%;
body {
  padding: 0;
  margin: 0;
}
.vertical {
  position: relative;
  background-color: #DDDDDD;
  padding: 10px;
  border-radius: 5px 5px 0 0;
  float: right;
  -moz-transform: rotate(270deg);
  /* FF3.5+ */
  -o-transform: rotate(270deg);
  /* Opera 10.5 */
  -webkit-transform: rotate(-90deg);
  /* Saf3.1+, Chrome */
  -moz-transform-origin: 100% 100%;
  -o-transform-origin: 100% 100%;
  -webkit-transform-origin: 100% 100%;
}
<div class="vertical">Vertical Text</div>
New Fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With