Skip to content

Instantly share code, notes, and snippets.

@JimBobSquarePants
JimBobSquarePants / centered-image.css
Last active Dec 23, 2015
Dimension Independent Centred Images - This allows an image to be centered within a parent container of a fixed height no matter what height or width the child image is. http://jsfiddle.net/jamessouth/JpCXX/
View centered-image.css
/*
* 1: Arbitrary width.
*/
.parent {
position: relative;
height: 250px;
max-width: 400px; /* 1 */
overflow: hidden;
}