这个问题我弄了好长时间,后来在blueidea搞定了
把代码发给你,自己研究一下吧 <!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" /> <title>css</title> <style type="text/css"> body {}
img {border:0;}
.article {width:100px; height:100px; background:#ccc;}
.article img { max-width: 100px; max-height: 80px; width: expression(onload=function(){if (this.offsetWidth>this.offsetHeight) {this.style.width=(this.offsetWidth > 100)?"100px":"auto"} {this.style.height=(this.offsetHeight < 80)?"auto":"80px"} }); } </style> </head> <body> <div class="article"> <img src="http://gg.blueidea.com/desk/2006/002.jpg" /> <br /> <img src="http://bbs.blueidea.com/images/blue/smilies/smile.gif" /> <br /> 容器width=100px </div> </body> </html>
|