Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center vertically child elements inside div [duplicate]

Tags:

html

css

Possible Duplicate:
How to make an image center (vertically & horizontally) inside a bigger div

HTML code:

<div class="promo_tumbs col_12">
    <div class="promo_tumb"></div>
    <div class="promo_tumb"></div>
    <div class="promo_tumb"></div>
    <div class="promo_tumb"></div>
    <div class="promo_tumb"></div>
</div>

CSS part:

.promo_tumbs {
    height: 155px;
    background: #058;
}
.promo_tumb {
    height: 75px;
    width: 125px;
    background: #990000;
    float: left;
    margin: 0 10px;
    text-align: center;
}

How can I vertically center .promo_tumb?

like image 534
Sasha Avatar asked Apr 23 '12 11:04

Sasha


1 Answers

Read this article on vertical centering.

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

If you dont wanna support IE7 or lesser then you can use vertical-align : middle.

Otherwise:

  1. Set display to table in .promo_tumbs col_12
  2. Set vertical-align to middle & display to table-cell for .promo_tumb

and it should work.

like image 188
Ashwin Krishnamurthy Avatar answered Oct 06 '22 01:10

Ashwin Krishnamurthy