怎么用div+css来控制图片的缩略图? 就象windows的缩略图那种 3楼 的能给个代码吗??网上看了很多都不可行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 等比例缩放!!!上传时就自动生成等比例缩放滴缩略图多省事!用JS只是模拟而已,如果图片很大时,页面加载速度会很慢!如果把照片里滴MM介绍给俺认识,那就告诉你,哈 <script language="JavaScript">//图片按比例缩放var flag=false;function DrawImage(ImgD,width,height){var image=new Image();var iwidth = width; //定义允许图片宽度var iheight = height; //定义允许图片高度image.src=ImgD.src;if(image.width>0 && image.height>0){flag=true;if(image.width/image.height>= iwidth/iheight){if(image.width>iwidth){ ImgD.width=iwidth;ImgD.height=(image.height*iwidth)/image.width;}else{ImgD.width=image.width; ImgD.height=image.height;}}else{if(image.height>iheight){ ImgD.height=iheight;ImgD.width=(image.width*iheight)/image.height; }else{ImgD.width=image.width; ImgD.height=image.height;}}}}</script><img id="imgpic" src="1.gif" onload="javascript:DrawImage(this,85,85);" />能用的话,记得给分啊,呵呵! to yixianggao :给出可行的代码(自己调试的),给上博客地址,呵呵:) 诚聘webgame开发工程师 关于Modal的一个问题``请进 鼠标在菜单上滑过缺少效果的问题! deleterow()问题,请高手指教 关于form表单提交的问题(在线等) javascript怎样比较两个时间的大小?只涉及时分秒 关于tablesorter排序表头一列多行 在javascript 里怎么把中划线 "-" 这个符号替换成空 ,另外一个是怎么用instr这个比较函数 熟悉mozilla的高手请进,关于关闭窗口的消息处理 令人头痛的问题 如何用js判断只能使用数字和小数点,并且小数点后只能有两位 如何在js中判断时间是否正确?
//图片按比例缩放
var flag=false;
function DrawImage(ImgD,width,height){
var image=new Image();
var iwidth = width; //定义允许图片宽度
var iheight = height; //定义允许图片高度
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= iwidth/iheight){
if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else{
if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}
</script>
<img id="imgpic" src="1.gif" onload="javascript:DrawImage(this,85,85);" />能用的话,记得给分啊,呵呵!