最近想在blog中的分类页面的缩略图让其自动适应,在网上搜索了一些代码,贴出来供大家参考。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style>
* {
margin: 0px;
padding: 0px
}
#photo {
margin:0 auto;
padding:0
}
#photo img {
max-width:300px;
min-width:300px;
min-height:200px;
height:200px;
width:expression(document.body.clientWidth>document.getElementById ("photo").scrollWidth*9/10? "300px": "auto")
} </style>
</head>
<body>
<div id="photo"> <img src="http://pic.jpgsky.com/infoPic/pic113/pic113972c1.jpg" /> </div> </body> </html>
还有一个:
<html>
<head>
<title>img max-width</title> <style type="text/css">
<!–
body {
text-align: center; margin: 50px; }
img {
max-width: 200px;
max-height: 200px;
width:expression(onload=function(){if (this.offsetWidth>this.offsetHeight){ this.style.width=(this.offsetWidth > 200)?"200px":"auto" } {this.style.height=(this.offsetHeight < 200)?"auto":"200px"} });
} –>
</style>
</head>
<body>
<a href="http://www.szrgb.net/szrgb/bbs/"><img src="http://pages.blueidea.com/articleimg/2006/09/1350/preview_b02.jpg" border="0" /></a><br> <br>
<a href="http://www.cps800.com/"><img src="http://www.cps800.com/adpicture/8year_right.gif" border="0" /></a> </body> </html>
这两个不错啦。
© 2010, Zeroun's Blog — 黄志勇博客,Diary,Pro/e,Catia,UG.PHP,手机开发,手机结构设计. 版权所有.

最新评论
钣金~没做过这么复杂的
不错哦!学习了嘿嘿!!
恩,会了
:razz: 呵呵, 好久没
来看看博主的文章
不错哦!!学习个撒嘿嘿
futher should
楼主你写的《公差分析实际应用
不错!!来这里转转!!
留下脚印
软件太大了, 无法传的.