Hi all

I have a div whose width and height are set to 120px and 90px respectively. Now i m showing re sized images in this div. I have an image whose width is 80px and height is 107px, now if i set image width and height to the same as div it solves my problem but it stretches the image and destroy quality of picture.

What i want is that my div should adjust the picture in middle with width of 80px and height of 90px, the remaining width area of div should have background color of black.

Hope it makes sense.

Member Avatar for stbuchok

Only set the height of the image, the width will auto adjust to a proper width without distortion.

so if your image is 80px width by 107px height and you set the height to 90px the width will auto adjust to 67px.

Hope this helps.

<div> styles alignment should be center and background color black!
inside the div use <img> with height and width auto !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.