Vertically center rotated text with CSS

前端 未结 7 1488
盖世英雄少女心
盖世英雄少女心 2020-12-07 11:56

I have the following HTML:

Centered?

div.

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-07 12:33

    The key is to set position top and left to 50% and then transformX and transformY to -50%.

    .inner {
        position: absolute;
        top: 50%;
        left: 50%;
    }
    
    .rotate {  
        transform:  translateX(-50%) translateY(-50%) rotate(-90deg);
    }
    

    see: http://jsfiddle.net/CCMyf/79/

提交回复
热议问题