Rotating a div element

前端 未结 5 983
忘掉有多难
忘掉有多难 2021-02-05 18:52

Is it possible to rotate a div element using Javascript & NOT using HTML 5?

If so what attributes of the element do I set/change to make it rotate? Ie, div.what?

5条回答
  •  渐次进展
    2021-02-05 19:34

    Old question, but the answer might help someone...

    You can rotate elements using proprietary CSS markup in all major browsers (the term HTML5 isn't specifically relevant here though).

    Example of how to rotate a element 45 degrees using CSS:

    .example {
        -webkit-transform: rotate(45deg); /* Chrome & Safari */
        -moz-transform: rotate(45deg); /* Firefox */
        -ms-transform: rotate(45deg); /* IE 9+ */
        -o-transform: rotate(45deg); /* Opera */
        transform: rotate(45deg); /* CSS3 */
        filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678, sizingMethod='auto expand'); /* IE 7-8 */
    }
    

    Yes, the MSIE syntax is that horrible. Note the "sizingMethod='auto expand'" - that's crucial to avoid the result being cropped.

    I'm fairly sure Matrix transforms (at least in some capacity) are also supported In MSIE 6, but it's more pernickety about under what circumstances it supports them (and it's increasingly hard to care 8).

提交回复
热议问题