1

This is a very common problem, but the technology moves on and new ways of doing this emerge. I'm currently trying to use flexbox for this purpose, but i now have another problem:

  • The container i need to center things in is 200x200 pixels (fixed size)
  • The image is unknown aspect ratio and unknown size
  • Image size can be higher or lower than the container
  • I need to downscale the image so that it is always less or equal to 98% of the container

If the image was square or landscape, i could do max-width: 98%. Is there any way to do the same for the image height?

Marius
  • 3,976
  • 5
  • 37
  • 52
  • whats wrong with `max-height`? Also if you show what you have tried, you might not get downvoted – stackErr Feb 04 '14 at 04:32
  • @stackErr i know about max-width and max-height, but i don't completely understand them and that's why i ask the question. If i specify both to 98% - will the image scale proportionally? – Marius Feb 04 '14 at 04:40
  • Can you create a fiddle to show what you want to achieve? – stackErr Feb 04 '14 at 04:41
  • 2
    possible duplicate of [Vertically align an image inside a div with responsive height](http://stackoverflow.com/questions/18516317/vertically-align-an-image-inside-a-div-with-responsive-height) – Hashem Qolami Feb 04 '14 at 04:47

0 Answers0