我有与表中的IMG显示一个问题:最大宽度在表
<table>
<tr>
<td>
<div>
<img src="https://www.google.ru/images/srpr/logo4w.png"/>
<img src="http://pictar.ru/data/media/24/nature__463_.jpg"/>
</div>
</td>
</tr>
</table>
利用CSS:
div {
height: 100%;
width: 100%;
border:2px solid red;
}
div img {
max-width: 100%;
max-height: 100%;
}
JS Fiddle example。
在Chrome中,这两个图像按比例缩放到div封装,但在Firefox和IE9图像中不能缩放。
我该如何在任何地方获得Chrome的行为?
答案:唯一的解决办法就是使用javascript。我的跨浏览器解决方案是:http://jsfiddle.net/TAE3w/21/
但是在这种情况下,Google图像的缩放比实际更大 – SerCe 2013-03-01 08:50:40
这很有趣,但我的问题是使所有三个浏览器的行为与Chrome中的第一个示例相同,我的问题特别描述[stackoverflow] (http://stackoverflow.com/questions/2923710/why-do-firefox-and-opera-ignore-max-width-inside-of-display-table-cell),但解决方案不适合我 – SerCe 2013-03-01 09:07:26
你会那么必须使用一些JavaScript。 – 2013-03-01 10:04:06