Rotating a div element

前端 未结 5 1048
忘掉有多难
忘掉有多难 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:37

    If you are looking for a way to do it instantaneously, than you can use element.style.transform = "rotateZ(90deg");
    Make sure to use quotes around the CSS statement.

    If you want it over the duration of, say, a second (I know you don't want this, I am just doing it anyways), you can put
    element.style.transition = "1s"; element.style.transform = "rotateZ(90deg)";

提交回复
热议问题