html - Vertically align text in a div -


i trying find effective way align text div. have tried few things , none seem work.

.testimonialtext {     position: absolute;     left: 15px;     top: 15px;     width: 150px;     height: 309px;     vertical-align: middle;     text-align: center;     font-family: georgia, "times new roman", times, serif;     font-style: italic;     padding: 1em 0 1em 0; } 

vertical centering in css
http://www.jakpsatweb.cz/css/css-vertical-center-solution.html

article summary:

for css2 browser 1 can use display:table/display:table-cell center content.

sample available @ jsfiddle:

  <div style="display: table; height: 400px; overflow: hidden;">      <div style="display: table-cell; vertical-align: middle;">        <div>          vertically centered in modern ie8+ , others.        </div>      </div>    </div> 

it possible merge hacks old browser (ie6/7) styles using # hide styles newer browsers:

<div style="display: table; height: 400px; #position: relative; overflow: hidden;">   <div style=     " #position: absolute; #top: 50%;display: table-cell; vertical-align: middle;">     <div style=" #position: relative; #top: -50%">      vertically centered     </div>   </div> </div> 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -