jquery text rotation

前端 未结 5 1384
隐瞒了意图╮
隐瞒了意图╮ 2021-02-13 12:43

I\'ve got a simple text inside a div, something like the following;

This is an example text
5条回答
  •  伪装坚强ぢ
    2021-02-13 12:58

    In standards-compliant browsers, you can use the CSS3 property transform, though it's probably a good idea to use vendor prefixes, e.g.:

    -o-transform: rotate(5deg);
    -khtml-transform: rotate(5deg);
    -webkit-transform: rotate(5deg); 
    -moz-transform: rotate(5deg);
    

    In Internet Explorer 6 and 7, things get tricky. You can use IE's filter property to do rotation.

    filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
    

    will rotate the element 90 degrees. You can also rotate 180 or 270 degrees using rotation=2 or rotation=3

    Do you want to rotate something in IE to a different angle? Are you ready for the headache?

    You can use IE's filter property again and specify matrix coordinates, and get something really ugly like this:

    progid:DXImageTransform.Microsoft.Matrix(M11=0.99619470, M12=0.08715574, M21=-0.08715574, M22=0.99619470,sizingMethod='auto expand');
    

    There are instructions on how to use the Matrix coordinates on this page, but frankly none of them make any sense. A better solution is to use this handy Matrix calculator that will generate the CSS you need when you specify the angle in degrees.

    You can check out the CSS on my site to see an example, but I haven't checked it using IE in a while, so I can't make any promises...

提交回复
热议问题