2

i have image inside div tag. when i change image (with high resolution) url from code behind , it shows scrolling for that div. How to fit image to div.

Here is my code

 <div class="imageCols">
    <img runat="server" id="imgOriginal" alt="orgImg" />
 </div>

imgOriginal.Src = "ProfilePictures/" + Session["WorkingImage"].ToString();

Arsen Mkrtchyan
  • 49,896
  • 32
  • 148
  • 184
baby
  • 91
  • 2
  • 5
  • 14
  • 1
    You can specify the height and width with css, but the full image is still being downloaded so if possible you might want to consider resizing the actual image. – Jack Aug 15 '13 at 13:46
  • A possible duplicate http://stackoverflow.com/questions/7336503/how-to-vertical-align-image-inside-div/11716065#11716065 – Tahir Yasin Aug 15 '13 at 13:48

2 Answers2

2

Try...

.imageCols img {
    width: 100%;
}
Dan Lister
  • 2,543
  • 1
  • 21
  • 36
0
.imageCols
{
  max-width:100%;
  max-height:100%;
}

Works in all modern browsers

Vitaly
  • 2,064
  • 19
  • 23