We have been trying to rotate a textbook at an angle(45,90,270 etc) on an aspx webform. I read that html won't support such a property, so we would have to include a CSS class property to the textbox. Is there a property to include an angle in a CSS class? We are using html 4.
2 Answers
Simple CSS will allow you to rotate any element in modern browsers:
transform: rotate(45deg);
This is a fairly new feature, and a lot of browsers support it, but require a vendor prefix, so you should also specify -moz-transform
, -webkit-transform
, -ms-transform
, so your full CSS will look like this:
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
This will support all browsers in common use except IE8 or earlier.
Old IE versions can rotate items, but it's much more difficult. You need to use the filter
style, but it requires angles in radians and complex matrix formulae. There is an answer here that describes it in more detail.
However, you could use a javascript library called CSS Sandpaper. Then you can simply use this for old IE versions:
-sand-transform: rotate(45deg);
Add the above line to the CSS block I gave you earlier, and include the CSS Sandpaper javascript library in your HTML page.
Hope that helps.
-webkit-transform: rotate(30deg);
-moz-transform: rotate(30deg);
-o-transform: rotate(30deg);
writing-mode: tb-rl;
for IE support to angle like 270 etc
/* Internet Explorer */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
-ms-transform:rotate(270deg); /* IE 9 */
filter can accept one of four values: 0, 1, 2, or 3 which will rotate the element 0, 90, 180 or 270 degrees respectively

- 2,532
- 1
- 17
- 23
-
writing-mode: tb-rl; is the property which supports IE7+ – Shafqat Masood Apr 26 '13 at 09:32
-
Writing-mode will tilt it vertically. What about angles like 45 and 270? – user997805 Apr 26 '13 at 09:35
-
IE is able to use `filter` to rotate by any angle, but it's much more complex. See http://stackoverflow.com/questions/4617220/css-rotate-property-in-ie for more info (or see my answer below for a nicer javascript-based alternative). – Spudley Apr 26 '13 at 11:52
-
Thank you very much for your response. Indeed helpful and informative. – user997805 Apr 26 '13 at 16:37