纯CSS实现图片水平垂直居中于DIV(图片未知宽高)

.demo{border:1px #ddd solid;width:267px;height:267px;overflow:hidden;text-align:center;display:table;float:left;margin:50px;position:relative;}
.demo a{display:table-cell;vertical-align:middle;width:267px;height:267px;}
.demo a img{margin:0 auto;max-width:267px;max-height:267px;}

纯CSS实现图片水平垂直居中于DIV(图片未知宽高)

原文地址:https://www.cnblogs.com/hellman/p/8340081.html