-1

The problem I'm having is that the image height will not stay in its container's boundaries.

The the max-width being applied to the image seems to work, however, the max-height doesn't.

HTML

<div class="row-layout">
  <div class="artist-image">
    <img >
  </div>
  <div class="artist-image">
    <img >
  </div>
  <div class="artist-image">
    <img >
  </div>
</div>

CSS

.row-layout {
   display: flex;
   flex-direction: row;
   width: 100%;
   height: 250px;
 }
.artist-image {
   flex-grow: 1;
   flex-shrink: 0;
   flex-basis: 0;
   display: flex;
   flex-direction: row;
   justify-content: center;
   align-items: center;
}
.artist-image > img {
   max-width: 100%;
   max-height: 100%;
}

Any ideas on how to fix this would be much appreciated.

2K01B5
  • 1,011
  • 1
  • 10
  • 23

1 Answers1

2

NEW (CHANGED) ANSWER:

Define the images as background-images of their containers, center those and choose background-size: contain. This will always show the full image in its original proportions, fitted to the size of the container:

.x {
  background: url(http://placehold.it/600x400) center center no-repeat;
  background-size: contain;
}

Here's the whole thing in a codepen: http://codepen.io/anon/pen/EKzQbK

Johannes
  • 64,305
  • 18
  • 73
  • 130