I have 3 images vertically aligned in fixed height div. How can I make sure that the top and bottom padding between them remains even when an image is added or deleted.
You want to:
display:table with a fixed height,![]()
in element with display:table-row and display:table-celldisplay:blockvertical-align:middleThis will cause the space to be evenly distributed vertically.
Code:



#img-list { display:table; height:100px }
#img-list img { height:20px; display:block }
#img-list li { display:table-row }
#img-list li span { display:table-cell; vertical-align:middle; background:red }
#img-list li:first-child,
#img-list li:last-child { height:20px }