Ezhno Ezhno - 1 year ago 91
CSS Question

Vertical Align text in a fluid div

I wonder how to align verticaly my text in a div.

I've tried things like

display: inline block;
but it didn't help.
My container is actually 10% height of the whole window.

Please see my code below, the refering div is "droite".


width: 73%;
height: 100%;
background-color: #232200;
text-align: center;
color: white;

width: 27%;
text-align: center;
float: left;
background-color: #afafaf;

#aszone, #gzone{
margin-left: 20px;
margin-right: 20px;
height: 10%;
background-color: black;
background-size: cover;

Answer Source

set parent(gzone) display:table; and child(.gauche,.droite ) display:table-cell;

 .gzone{ display:table; }  
 .gauche,.droite { display:table-cell; vertical-align:middle; }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download