昨天自己的一个网站需要实现图片等比例缩放,但又不能使用js只能用css控制div中的img为指定大小,下面我找到一段代码分离给大家。
代码如下
复制代码
<style type="text/css">
.thumbImage img{
MAX-WIDTH: 100%!important;HEIGHT: auto!important;width:expression(this.width > 600 ? "600px" : this.width)!important;
}
.thumbImage {MARGIN: auto;WIDTH: 600px;}
*html.thumbImage img{
width:expression(this.width>600&&this.width>this.height?450:auto);
height:expresion(this.height>450?450:auto);
}
</style>
html代码
代码如下
复制代码
<body>
<DIVclass="thumbImage" ><imgsrc="2007910112041114.jpg"border="0"></DIV>
</body>
这样只要在 class中thumbImage图片都会等比例缩放哦,小了就原始显示大的就等比例缩校