【发布时间】:2015-04-22 08:59:47
【问题描述】:
我有 5 个图像的数组,我用 PHP 显示。如何使用 JavaScript 显示它们,使每张图片都比上一张低 10%?
foreach($top_images as $top_i) {
echo '#'.$ratio;
echo '
<br><img src="'.$top_i['url'].'" ><br>
<script type="text/javascript">
$(document).ready(function(){
var img = new Image();
img.src = "'.$top_i['url'].'";
img.onload = function() {
var width = this.width;
var height = this.height;
ratio = '.json_encode($ratio).';
this.width = this.width - this.width * ratio/10;
this.height = this.height - this.height * ratio/10;
}
});
</script>
';
$ratio++;
}
【问题讨论】:
标签: javascript image image-scaling