img {
width: auto; /* set to anything and aspect ratio is maintained - also corrects glitch in Internet Explorer */
height: auto; /* set to anything and aspect ratio is maintained */
max-width: 100%;
border: 0; /* for older IE browsers that draw borders around images */
}
4 回答
这符合您的需求吗?
见http://jsfiddle.net/7s9wnjse/1/ .
编辑:让答案更简单 .
使用背景尺寸:封面;
小提琴:http://jsfiddle.net/SinisterSystems/cukgh/3/
这会给你你想要的东西:
CSS
在此处查看并重新调整窗口大小以查看 .
基本上,只需给自己一份 Normalize.css .
如果高度是固定的,它将不会保持纵横比,将它们设置为您想要的最大值,并保持比率 .
编辑:
看看你的图片标签,他们可能已经设置了它们的宽度和高度 . 如果是这种情况,你需要删除它们 .
如果它上面有宽度和高度,你将无法用css修复 .