我有一张图片是 宽100 高200 页面上一个img控件是100*100的 怎么让这个控件显示这个图片又不压缩图片
解决方案 »
- goody9807老大,再次求教 !!!!!
- iewebcontrols这一个组件怎么样装
- 思归,孟子等大虾专家帮忙,如何将Asp.net页面输出为格式良好的XML文档
- 在一个frameset的frame中有个html的select控件,通过选择不同的值改变另一个frame的页面自动刷新时间
- 谁能帮帮我做设计
- 页面长时间打开,导致ie死掉?
- 紧急求助:怎么样在datalist中进行判断?
- 哪位大虾知道比较好的.net反编译工具?
- 请教各位大虾:请问怎样判断 radiobutton 选种的值,然后提交到收据库中,并且判断显示在出来。
- 银联ChinaPay开发,安全性异常
- Repeater嵌套Repeater js实现单选问题
- 页面打开很慢,奇怪
本群新开,欢迎dotnet程序员加入,我们致力于营造一个好的学习交流氛围,不管你是高手还是菜鸟,只要你虚心好学,我们都诚挚的欢迎您。
当如果你是想让你变成100*100 而不会变成100*200的话
我是用CSS的
.imgItem
{
width :200px;
height :210px;
}
就相当于说
你把 一个 100*100 大小的图片
放到一个 800*600的Img 控件上面去 那图片 会扩大吗
要么你将img控件的 height 和 width 属性去掉,否则得不倒你想要的结果。
<script language="JavaScript">
var flag=false;
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= 140/120){
if(image.width>140){
ImgD.width=140;
ImgD.height=(image.height*140)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else{
if(image.height>120){
ImgD.height=120;
ImgD.width=(image.width*120)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}
</script>
onload="javascript:DrawImage1(this)">