问一个表格中动态调整图片大小的问题

wythz 2005-08-24 03:23:52
我有一个表格(2X2),每个单元格里显示一张图片,但是现在的问题是,图片的尺寸是不固定的,有的图片小,有的图片又很大,我给每个单元格设定的大小是320*240,现在我想让超过这个尺寸的图片自动填满单元格(图片会被挤压,这个没关系),尺寸小于这个单元格的图片保持原来大小(不要它被拉伸),就用html能不能实现?
...全文
391 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wythz 2005-08-27
  • 打赏
  • 举报
回复
ok
3x
adandelion 2005-08-24
  • 打赏
  • 举报
回复
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
<!--
function setImg(obj)
{
if (obj.width>100) obj.width=100;
if (obj.height>50) obj.height=50;
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<TABLE>
<TR>
<TD><IMG SRC="../My Documents/My Pictures/样品.jpg" id ="img1" BORDER="0" ALT="" onload ="setImg(this);"></TD>
<TD><IMG SRC="../My Documents/My Pictures/样品.jpg" id ="img2" BORDER="0" ALT="" onload ="setImg(this);"></TD>
</TR>
<TR>
<TD><IMG SRC="../My Documents/My Pictures/样品.jpg" id ="img3" BORDER="0" ALT="" onload ="setImg(this);"></TD>
<TD><IMG SRC="../My Documents/My Pictures/样品.jpg" id ="img4" BORDER="0" ALT="" onload ="setImg(this);"></TD>
</TR>
</TABLE>
</BODY>
</HTML>
adandelion 2005-08-24
  • 打赏
  • 举报
回复
上面是只设顶了高的,下面高和宽都设置了,但这样图片会变相。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<TABLE>
<TR>
<TD><IMG SRC="../My Documents/My Pictures/样品.jpg" id ="img1" BORDER="0" ALT="" onload ="if (this.width>100) this.width=100;if (this.height>50) this.height=50;"></TD>
<TD><IMG SRC="../My Documents/My Pictures/样品.jpg" id ="img2" BORDER="0" ALT="" onload ="if (this.width>100) this.width=100;if (this.height>50) this.height=50;"></TD>
</TR>
<TR>
<TD><IMG SRC="../My Documents/My Pictures/样品.jpg" id ="img1" BORDER="0" ALT="" onload ="if (this.width>100) this.width=100;if (this.height>50) this.height=50;"></TD>
<TD><IMG SRC="../My Documents/My Pictures/样品.jpg" id ="img2" BORDER="0" ALT="" onload ="if (this.width>100) this.width=100;if (this.height>50) this.height=50;"></TD>
</TR>
</TABLE>
</BODY>
</HTML>
adandelion 2005-08-24
  • 打赏
  • 举报
回复
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<TABLE>
<TR>
<TD><IMG SRC="../My Documents/My Pictures/样品.jpg" id ="img1" BORDER="0" ALT="" onload ="if (this.width>100) this.width=100;"></TD>
<TD><IMG SRC="../My Documents/My Pictures/样品.jpg" id ="img2" BORDER="0" ALT="" onload ="if (this.width>100) this.width=100;"></TD>
</TR>
<TR>
<TD><IMG SRC="../My Documents/My Pictures/样品.jpg" id ="img1" BORDER="0" ALT="" onload ="if (this.width>100) this.width=100;"></TD>
<TD><IMG SRC="../My Documents/My Pictures/样品.jpg" id ="img2" BORDER="0" ALT="" onload ="if (this.width>100) this.width=100;"></TD>
</TR>
</TABLE>
</BODY>
</HTML>
wythz 2005-08-24
  • 打赏
  • 举报
回复
没人知道么,我自己顶一下

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧