Home › Forums › CSS › Vertikal centering responsive bootstrap div › Reply To: Vertikal centering responsive bootstrap div
November 11, 2013 at 11:32 am
#155705
LlewellynCollins
Participant
You can try use flexbox see this answer http://stackoverflow.com/questions/15726740/vertically-centre-items-with-flexbox
Or you can do it with code. Get the height of the box with javascript maybe also listen to the window resize event to make sure it is up to date. Then with postion: absolute and top: 50% have the margin-top be negative half the height of the box. eg #box{
position: absolute;
top:50%;
margin-top: -50px; /* if the height is 100px */
}