How can I rotate an HTML
90 degrees?

后端 未结 6 2034
感情败类
感情败类 2020-11-28 22:45

I have a

that I want to rotate 90 degrees:

How can I do this?

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 23:42

    Use transform: rotate(90deg):

    #container_2 {
        border: 1px solid;
        padding: .5em;
        width: 5em;
        height: 5em;
        transition: .3s all;  /* rotate gradually instead of instantly */
    }
    
    #container_2:hover {
        -webkit-transform: rotate(90deg);  /* to support Safari and Android browser */
        -ms-transform: rotate(90deg);      /* to support IE 9 */
        transform: rotate(90deg);
    }
    This box should be rotated 90° on hover.

    Click "Run code snippet", then hover over the box to see the effect of the transform.

    Realistically, no other prefixed entries are needed. See Can I use CSS3 Transforms?

提交回复
热议问题