简体   繁体   English

Javascript调整所有图像的大小

[英]Javascript Resize all Images

im trying to resize all images on a page. 我试图调整页面上所有图像的大小。 After googleing 1 day, I ended in the following code: google 1天后,我输入了以下代码:

<script type="text/javascript">
<!--
window.onresize = function(){
var images = document.images;
images.style.width = "100%";
};


-->
</script>

Could someone tell me please, why this wont work? 有人可以告诉我,这为什么不起作用? :/ :/

Greets SG SG的问候

Two points why dont you use css for this, im not sure why you would need to use javascript. 两点,为什么不为此使用CSS,我不确定为什么需要使用JavaScript。

img{width:100%;}

Second in your example your code is commented out and also images creates an array that you will need to loop through seeZoltan Toth answer 在您的示例的第二个位置,您的代码被注释掉了,并且图像还创建了一个数组,您将需要遍历seeZoltan Toth答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM