img{ width: auto; height: auto; max-width: 100%; max-height: 100%; }
根据父容器的自动缩放,并保持图片原来的比例。这样你设置父容器的大小就可以啦。