Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotating 90 degrees in CSS in IE8 and lower

How can I rotate 90 degrees in IE 8 and lower, using only CSS?

.horizontal {
   display: block;
   width: 300px;
   height: 100px;/*height*/
   background: #FF0000;
   margin: auto;
   margin-top: 110px;
   text-align: center;
   border: 5px solid #000000;

   -webkit-transform: rotate(-90deg);
   -moz-transform: rotate(-90deg);
   -o-transform: rotate(-90deg);
   -ms-transform: rotate(-90deg);
   transform: rotate(-90deg);
}
like image 738
Ronny Perez Avatar asked Jul 29 '13 03:07

Ronny Perez


People also ask

How do you rotate CSS 90 degrees?

Solution with the CSS transform property You need to add the width and height properties for the container and specify the transform property with the “rotate(90deg)” value.

How do you rotate counterclockwise in CSS?

A positive value will rotate the element in the clockwise direction. A negative value will rotate it in the counter-clockwise direction. Examples: transform: rotate(45deg); transform: rotate(-60deg); transform: rotate(1.5rad); transform: rotate(1turn);

How do you rotate something in CSS?

Rotating an image using CSS Once the CSS code is applied to your . css file, stylesheet, or <style> tags, you can use the CSS class name in any of your image tags. To rotate an image by another measure of degrees, change the "180" in the CSS code and <img> tag to the degree you desire.

How do you rotate something 90 degrees in HTML?

An element can be rotated 90 degrees by using the transform property. This property is used to move, rotate, scale and others to perform various kinds of transformation to elements. The rotate() transformation function can be used as the value to rotate the element.


2 Answers

You want to use filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);

CSS

.horizontal {
    display: block;
    width: 300px;
    height: 100px;/*height*/
    background: #FF0000;
    margin: auto;
    margin-top: 110px;
    text-align: center;
    border: 5px solid #000000;

    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    -o-transform: rotate(-90deg);
    -ms-transform: rotate(-90deg);
    filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
    transform: rotate(-90deg);
}

More information on this

like image 85
3dgoo Avatar answered Oct 18 '22 03:10

3dgoo


writing-mode which is currently in the CSS3 draft specification allows us to accomplish text rotation without using propriety properties, effectively future proofing the concept as more browsers adopt the CSS3 draft spec.

p { writing-mode: tb-rl; }

That’s it incredibly simple CSS technique that will eventually work with all browsers as their CSS3 support gets better. This is one of the handful of CSS3 supported properties in IE. The tb-rl value tells the browser to display paragraphs with the text flowing from top to bottom, right to left. Essentially rotating the text 90 degrees clockwise and aligning to the right.

This properties true intention is for displaying other languages in their correct “writing mode” such as Japanese right to left or Arabic & Hebrew which display right to left & top to bottom (rl-tb).

Support

At the moment IE is the only browser to support it starting from IE5.5 and up, IE8 adds further values through using the -ms extension. There are 4 values available from IE5.5+ and an additional 4 values for IE8+ through the -ms extension.

  • lr-tb – This is the default value, left to right, top to bottom
  • rl-tb – This flows the text from right to left, top to bottom
  • tb-rl – Flows the text vertically from top to bottom, right to left
  • bt-rl – bottom to top, right to left
  • tb-lr – This and the followings value are only available in IE8+ using -ms-writing-mode. Text flows top to bottom, left to right
  • bt-lr – Bottom to top, left to right
  • lr-bt – Left to right, bottom to top
  • rl-bt – Right to left, bottom to top

Rotate text in other browsers?

-webkit-transform: rotate(90deg);   
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);

Online Demo

-ms-writing-mode property

like image 2
Jebasuthan Avatar answered Oct 18 '22 03:10

Jebasuthan