/ Published in: CSS
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
HTML: <div class="contentdiv"> <p>It works! Vertically Center Align!</p> </div> CSS: .contentdiv{ width: 135px; height: 84px; display: table; border:2px solid red;} .contentdiv p{ display: table-cell; vertical-align: middle; text-align: center;} Hack for ie: .contentdiv p{*margin-top: expression(this.offsetHeight < this.parentNode.offsetHeight ? parseInt((this.parentNode.offsetHeight - this.offsetHeight) / 2) + "px" : "0");}
URL: http://htmlcsstutorials.blogspot.com/2009/07/vertical-align-text-in-floating-div.html