0

I have <img> tag of height = "100%" width = "30%". when I click on upload file , the selected image is viewed in <img> tag. But the image gets stretched or squeezed as per resolution. How to show full image in <img> tag?

Markus W Mahlberg
  • 19,711
  • 6
  • 65
  • 89
abcd1234
  • 5
  • 4

1 Answers1

0

Set either one or the other, not both (in terms of width or height):

img{
  width:50%;
  }
<img src="https://placekitten.com/g/200/300"/>

Notice how an image (usually 200*300) is now stretched to 50% of the width of the screen, and its height will adjust accordingly?

jbutler483
  • 24,074
  • 9
  • 92
  • 145
  • now here instead of scroll i want full image to be viewed in that rectangle div (small size as per resolution without affecting actual look of image). – abcd1234 Jan 05 '15 at 12:51
  • then remove the css altogether. The image will be its native size. – jbutler483 Jan 05 '15 at 12:52
  • the size of my div is half the screen . removing css gives scroll to div because of resolution. I want to resize the image to show it inside div. – abcd1234 Jan 05 '15 at 13:12
  • has the containing div got a specific height? if so in your image you can set max-height: /*height of containing div*/ – jbutler483 Jan 05 '15 at 13:19
  • but then it stretches the image. – abcd1234 Jan 05 '15 at 13:27
  • if this answered your question, could you possibly mark it as accepted? (by pressing the tick on the left hand side of my answer) – jbutler483 Jan 06 '15 at 08:56