Reputation: 537
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.
Upvotes: 10
Views: 16138
Reputation: 4549
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>
Upvotes: 29