css图片等比例缩放

来源:互联网 发布:数据库第三章课后答案 编辑:程序博客网 时间:2024/05/17 07:15
css样式代码
<style type="text/css">
img {max-width:500px; max-height:500px; scale:expression((this.offsetWidth > this.offsetHeight)?(this.style.width = this.offsetWidth >= 500 ? "500px" : "auto"):(this.style.height = this.offsetHeight >= 500 ? "500px" : "auto")); display:inline !important;}
</style>
示例中是默认网页所有的img的标签中的图片都会缩放,如果想让特定的图片缩放只要修改下前面的css名字,然后在网页中调用就可以了