Vertically center rotated text with CSS

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

I have the following HTML:

Centered?

div.

7条回答
  •  伪装坚强ぢ
    2020-12-07 12:37

    It may be a bit late for answering that question, but I stumbled on the same issue and found some way of achieving it, by adding another div in the way.

    Centered?

    and applying a text-align: center on that middle element, along with some positioning stuff:

    .middle {
        margin-left: -200px;
        width: 400px;
        text-align: center;
        position: relative;
        left: 7px;
        top: 50%;
        line-height: 37px;
    }
    

    The .inner also gets a display: inline-block; to enable both rotate and text-align properties.

    Here is the corresponding fiddle : http://jsfiddle.net/CCMyf/47/

提交回复
热议问题