简体   繁体   English

如何根据div标签图像自动调整图像大小

[英]how to resize image according to div tag image automatic

我想根据自动更改div标签的大小来调整div标签内的图像的大小。如何使用j查询实现帮助,请帮助我们注意图像位于div标签内。

The answer is simple add width: 100% to style. 答案很简单:增加宽度:样式的100%。 Like so: 像这样:

<img src='image_url.jpg' style='width: 100%' alt='image_name'/>

Here is the code. 这是代码。

    <div id="img_box">
    <img src="path/to/horizontal_image.jpg" style="width: 100%" />
    </div>

Also have a look at the link below. 也请看下面的链接。

http://www.webmasterworld.com/css/3828593.htm http://www.webmasterworld.com/css/3828593.htm

http://www.codingforums.com/showthread.php?t=145288 http://www.codingforums.com/showthread.php?t=145288

with jQuery: 使用jQuery:

$('.divSelector').find('img').css({
  'width': '100%',
  'height': '100%'
});

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

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