Tag Archives: How to set the margin or padding as percentage of height of parent container?

How to set the margin or padding as percentage of height of parent container?

Question I had been racking my brains over creating a vertical alignment in css using the following .base{ background-color:green; width:200px; height:200px; overflow:auto; position:relative; } .vert-align{ padding-top:50%; height:50%; } and used the following div structure. <div class=”base”> <div class=”vert-align”> Content Here </div> </div> While this seemed to work for this case, i was surprised that when… Read More »