center vertically the content of a div ( not by line-height )

后端 未结 4 1519
余生分开走
余生分开走 2021-01-26 12:20

I have a div which I need to center vertically its content:

Free coffee for all the people who visit my restaurant&l
4条回答
  •  无人共我
    2021-01-26 12:53

    You have to add a second div to achieve this.

    Free coffee for all the people who visit my restaurant
    #coffee { display: table; width: 300px; background-color: red; } #coffee .inner{ vertical-align: middle; display: table-cell; }

    Example: http://jsfiddle.net/2Mb39/12/

提交回复
热议问题