/ Published in: CSS
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
.wrap { display: table; height: 400px; #width: 175px; /* arbitrary width for IE only */ #position: relative; /* for IE only */ overflow: hidden; } .inner { #position: absolute; /* for IE only */ #top: 50%; /* for IE only */ display: table-cell; vertical-align: middle; } .content { #position: relative; /* for IE only */ #top: -50%; /* for IE only */ } .wrap, .content {border: 1px solid green;} /* just borders to see it */ p {padding:5px;} <div class="wrap"> <div class="inner"> <div class="content"> <p>Any content vertically centered.</p> </div> </div> </div>