用原生的JavaScript實現的圖片等比例縮放
jQuery部分代碼
<script type="text/javascript">
$(document)
var maxWidth=$("
$("img")
if(!$
var imgWidth=$(this)
var imgHeight=$(this)
var maxHeight = maxWidth*imgHeight/imgWidth;
if(imgWidth>maxWidth){
$(this)
}
}
})
})
</script>
css部分代碼
<style type="text/css">
body{ margin:
img{ border:
</style>
html代碼
<div class="box">
<div class="imgBox">
<img src="images/
</div>
</div>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20016.html