vertical text center in

后端 未结 3 396
渐次进展
渐次进展 2021-01-28 00:40

So i am trying get 2 div-containers which both should contain centered text (Both x- and y-axis).

Thanks to Google and stackoverflow, i stumbled over a few workarounds w

相关标签:
3条回答
  • 2021-01-28 01:04

    Basically first you have to define the parent element as table from CSS and then you can display its child element as a table cell.

    For example,

     div.parent {
        display: table;
     }
     div.parent div.child {
        display: table-cell; 
         vertical-align: middle;  
    }
    

    Check out this link, it would clarify your queries.. http://css-tricks.com/vertically-center-multi-lined-text/

    0 讨论(0)
  • 2021-01-28 01:20

    Vertical-align:middle property is not used with position:absolute; if you are using vertical-align:middle then try this layout modified layout http://jsfiddle.net/7Rgvs/5/

    0 讨论(0)
  • 2021-01-28 01:20

    use display: table for the (holder #left-menu element) and display: table-cell for the inner holder element and use this styles:

    #left-menu .inner {
        display: table-cell;
        margin: 0 auto;
        text-align: center;
        vertical-align: middle;
        width: 100%;
    }
    

    i have edit the left menu inside your fiddle: http://jsfiddle.net/7Rgvs/

    0 讨论(0)
提交回复
热议问题