0

The following code works well:

<div id="container">
   <p>test</p>
</div>

#container{height:500px;display:table-cell;vertical-align:middle;}

but when the containerelement has the css property:float:left

it cannot work!!

I just want vertical-middle while floating

jin
  • 15
  • 3

1 Answers1

0

You must set line-height in this case:

line-height:500px

Ghilas BELHADJ
  • 13,412
  • 10
  • 59
  • 99
  • but multiple lines content,it doesnot work. – jin Jul 19 '13 at 08:31
  • [http://css-tricks.com/vertically-center-multi-lined-text/](http://css-tricks.com/vertically-center-multi-lined-text/) – jin Jul 19 '13 at 08:47