展会信息港展会大全

图片自适应大小 android软件开发教程
来源:互联网   发布日期:2016-03-25 16:02:47   浏览:1552次  

导读:代码如下 复制代码 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd html xmlns=http://www.w3.org/1999/xhtml head meta http-equiv=Content-Type content=text/html; charset=utf-...

代码如下

复制代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript">

var flag=false;

function DrawImage(ImgD,imageWidth,imageHeight) {

var image=new Image();

image.src=ImgD.src;

if(image.width>0 && image.height>0){

flag=true;

if(image.width/image.height>= imageWidth/imageHeight){

if(image.width>imageWidth){

ImgD.width=imageWidth;

ImgD.height=(image.height*imageWidth)/image.width;

}else{

ImgD.width=image.width;

ImgD.height=image.height;

}

}

else{

if(image.height>imageHeight){

ImgD.height=imageHeight;

ImgD.width=(image.width*imageHeight)/image.height;

}else{

ImgD.width=image.width;

ImgD.height=image.height;

}

}

}

}

</script>

<title>Anddecor</title>

</head>

<body>

<img alt="\" src="pic01.gif" onload= "javascript:DrawImage(this,150,130)" />/*定义图片宽不超过150,高不超过130*/

</body>

</html>

赞助本站

人工智能实验室

相关热词: 开发 编程 android

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港