<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function Adjust(phoid, iwidth, iheight) {
var p = document.getElementById(phoid);
if (p.height > iheight) {
p.height = iheight;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<img src="http://c.csdn.net/bbs/t/5/i/pic_logo.gif" id="pho1" alt="ss" />
</div>
<input type="button" onclick="Adjust('pho1', 10,10);" value="hit" />
<script> </script>
</form>
</body>
</html>
用JS这样设置图片高度,为什么图片宽度也会按比例缩小呢?可以只缩小高度,不影响宽度吗?
<head runat="server">
<title></title>
<script type="text/javascript">
function Adjust(phoid, iwidth, iheight) {
var p = document.getElementById(phoid);
if (p.height > iheight) {
p.height = iheight;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<img src="http://c.csdn.net/bbs/t/5/i/pic_logo.gif" id="pho1" alt="ss" />
</div>
<input type="button" onclick="Adjust('pho1', 10,10);" value="hit" />
<script> </script>
</form>
</body>
</html>
用JS这样设置图片高度,为什么图片宽度也会按比例缩小呢?可以只缩小高度,不影响宽度吗?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货