其他分享
首页 > 其他分享> > HTML控制图片居中缩放

HTML控制图片居中缩放

作者:互联网

<html>
<head>
</head>
<body>
<div style="display:table;text-align:center;width:100%;height:100%;" onm ousewheel="bbimg();">
	<span style="display:table-cell;vertical-align:middle;">
	<img id="img1" src="https://www.baidu.com/img/baidu_jgylogo3.gif" />
	</span>
</div>

<script type="text/javascript">
function bbimg(){
	var img=document.getElementById("img1");
	var zoom=parseInt(img.style.zoom, 10) || 100;
	zoom+=event.wheelDelta/12*3;
	
	if(zoom>0) img.style.zoom=zoom+'%';
}
</script>
</body>
</html>

  

标签:居中,style,12,img,缩放,zoom,HTML,var
来源: https://www.cnblogs.com/PER10/p/16523194.html