Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Comments
[no name] 16-Jul-12 9:36am    
"Image is placed properly", "Image is not placed properly.", "I had tried but, I can't.", "I had no code at presnt"... So the image is placed properly and not placed properly, you tried but have no code. What kind of question is this.

HTML
<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!
 
Share this answer
 
v2
Fix the size of image instead of div:-
HTML
<div>
  <img src="yourimage.jpg" alt="not found" width="302" height="302" />
</div>


or you can use inline css code:
HTML
<div>
   <img src="yourimage.jpg" alt="not found" style="width:302px; height:302px;" />
 </div>


Hope it will help you.
Good luck.
 
Share this answer
 
v2
Comments
Yashwanths 16-Jul-12 8:19am    
Hi,
Send me your mail id,I will attach the file,then u will get more understand about my question.
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
HTML
style="overflow: auto;" 
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
 
Share this answer
 
v2
Comments
Yashwanths 16-Jul-12 7:46am    
I had tried what u sad but,the both horizontal and vertical scrollbars are apperaed for the div.And also,the image is also showing very big when we given the big image and very small when we given the small image.

I want when the big (or) small image is given,it should be displayed in that div only without scrollbar
AshishChaudha 16-Jul-12 7:59am    
Fix the size of your Image control, In any case your image will fix to 302x302 whether it is big or small

<img src="[your image path]" style="width:302px; height:302px;" alt="your image display tip" />
Yashwanths 16-Jul-12 8:05am    
once see the website www.dollarforthepoor.com
Here, after login with facebook the page will appear,then u can identify clearly what I am telling.
AshishChaudha 16-Jul-12 8:13am    
What page will appear.. I didnt understand..please show us the code what you are doing so we can help you better. "Improve your question". Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900