2

I have different images and I want to keep them in a same height and width.

My code structure is:

<figure>
    <img src="..img/image.png" />
</figure>

I have about four of these elements.

My css are:

figure{
 overflow: hidden;
 max-height: 200px;
}

.thumbnail figure img {
  max-height: 200px;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
 }

This is helping me to keep the same height and width.

But the problem is:

If i place a image with large pixel ratio it looks large. For example, if I use a pic with a man with high resolution, it shows only the eyes and nose.

What can I do now?

Candlejack
  • 448
  • 10
  • 23
muhaimin
  • 119
  • 1
  • 12

2 Answers2

0

I think this might be useful to you.

give the max-height: 200px just as you like. suppose if your normal image has dimensions 400X400(in pixels), you can crop the image to 200px but you are saying that is fine. Your problem starts with images with higher resolution. In this case you give max-width of figure to 200px and lower the height and width of the image than the original size. Suppose your image has dimensions 800X800(in pixels), reduce width and height of the image, say (width: 400px; height: 400px;), then you may see atleast face instead of only having nose or eyes. If you want to see more part of image, you should reduce the size of image much lower.

But i suggest you to compress the image if u have high resolution images. (http://www.resize-photos.com/)

I think it should work. Please post the result if this doesn't works

figure{
 overflow: hidden;
 max-height: 200px;
}

.thumbnail figure img {
  max-height: 200px;
  width: (lower than original width);
  height: (lower than original height);
  position: relative;
  left: 50%;
  transform: translateX(-50%);
 }
Akash Pinnaka
  • 465
  • 4
  • 23
0

This might be a solution to your problem, if you specify the max-width for the img separate it will constrain very large images from becoming useable

figure{
 overflow: hidden;
 max-height: 200px;
}

.thumbnail figure {
  max-height: 200px;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
 }

 img {
   max-height: 500px;
 }

https://jsfiddle.net/jwyjwrej/

Stef Kors
  • 310
  • 2
  • 12