<!--
// 说明:用 javascript 实现网页图片等比例缩放
// 整理:http://www.codebit.cn
function drawimage(imgd,fitwidth,fitheight)
{
var image=new image();
image.src=imgd.src;
if(image.width>0 && image.height>0)
{
if(image.width/image.height>= fitwidth/fitheight)
{
if(image.width>fitwidth)
{
imgd.width=fitwidth;
imgd.height=(image.height*fitwidth)/image.width;
}
else
{
imgd.width=image.width;
imgd.height=image.height;
}
}
else
{
if(image.height>fitheight)
{
imgd.height=fitheight;
imgd.width=(image.width*fitheight)/image.height;
}
else
{
imgd.width=image.width;
imgd.height=image.height;
}
}
}
}
我的js库
最新推荐文章于 2023-05-10 16:20:18 发布