图像放置正确 [英] Image is placed properly

查看:65
本文介绍了图像放置正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



图像放置不正确.

我有一个高度和宽度为302 * 302的div,

我想放置图像,无论图像大小是多少(例如:-1024 * 768,250 * 250)

该图像必须在该区域中完全可见.


我曾经尝试过,但是我不能.


请帮我

Hi,

Image is not placed properly.

I have a div with height and width as 302*302 then,

I want to place the image,whatever the image size should be(eg:-1024*768,250*250)

The image must be viewed as completely in that div.


I had tried but, I can''t.


Plz help me

推荐答案

<div style="width:302px; height:302px;">
  <img src="image.jpg" style="width:302px; height:302px;" alt="my image" />
</div>


这将完成任务,但不建议这样做.因为您的客户将必须下载可能更大的图像,然后再进行下载.这里的另一个问题是不保留图像比例.

您应该先缩放图像,然后再将其发布到网络上!


This will du the job, but it''s NOT recommended. Because you''r client will have to download a potentially much larger image then necessary. Another issue here is that the images proportions is not kept.

You should scale your images before publishing them to the web!


固定图像的大小,而不是div:-
Fix the size of image instead of div:-
<div>
  <img src="yourimage.jpg" alt="not found" width="302" height="302" />
</div>



或者您可以使用内联CSS代码:



or you can use inline css code:

<div>
   <img src="yourimage.jpg" alt="not found" style="width:302px; height:302px;" />
 </div>



希望对您有帮助.
祝你好运.



Hope it will help you.
Good luck.


如果您将DIV 的大小固定为图像标签之外的302x302,那么图像的大小将不会超过302x302方面.您可以将
If you have fixed the size of your DIV to 302x302 which is outside the image tag then what ever the size of the image will be it will not exceed avobe than 302x302 dimensions. You can put the
style="overflow: auto;" 

,因此如果图像尺寸大于302x302,则Scrollbars 将是可见的.


您还可以将图像的大小固定为与DIV 大小相同.(302x302)

谢谢
灰烬

of the DIV, so the Scrollbars will be visible, if the image size is greater than 302x302.
or

You can also fix the size of the image same as the DIV size.(302x302)

Thanks
Ashish


这篇关于图像放置正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆