使用js对图片按照实际大小进行展示

图片:

<img src="http://xxx.jpg" id="imgs" onload="adapt();"/>

无需设置 width 、height

添加css样式:

<style type="text/css">
<!--
	img{
		max-width:100%;max-height:100%;
	}
-->
</style>

即可对图片进行按实际大小进行展示。

猜你喜欢

转载自blog.csdn.net/feng_qin19936/article/details/81261607