`
smallwolf
  • 浏览: 20459 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类

auto reduce the image size

阅读更多
1.use the css style
<style type="text/css">
.content-width {MARGIN: auto;WIDTH: 600px;}
.content-width img{MAX-WIDTH: 100%!important;HEIGHT: auto!important;width:expression(this.width > 600 ? "600px" : this.width)!important;}
</style>
</head>
<body>

<div class="content-width">
  <p><img src="/down/js/images/12567247980.jpg"/></p>
  <p><img src="/down/js/images/12567247981.jpg"/></p>
</div>

2. use javascript code
  <script language="JavaScript">
var imgObj;
for( i = 0; i < document.getElementsByTagName("img").length; i++ )
{
 imgObj = document.getElementsByTagName("img")[i];
 if ( imgObj.width > 400) 
 {
  imgObj.width = 400
 }
 if ( imgObj.height > 400 ) 
 {
  imgObj.height = 400
 }
}
</script>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics