Variable sized centering with absolute positioning and auto margins
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
// alert('Hello world!');
<div>
a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z
<img src="http://placehold.it/200x270">
</div>
/* Variable sized centering with absolute positioning and auto margins */
body {
font: bold 2em/1 sans-serif;
}
div {
position: relative;
background: gray;
height: 10em;
width: 10em;
padding: 1em;
margin: 0 auto;
overflow: hidden;
text-align: center;
}
img {
position: absolute;
top: 0;
left: 0;
right: 0;
margin: auto;
bottom: 0;
box-shadow: 0 0 1em rgba(0,0,0,.6);
}