0

How to make my imgs not to overflow outside its container <div class="display"> and perfectly make a square/box?

It should've work for flexbox.

As you can see, this snippets resulting 3 images with 1 outside which not properly a box.

.display {
  min-width: 500px;
  max-width: 500px;
}

.scenery {
  display: flex;
  flex-direction: column;
}

.scenery_1 {
  display: flex;
}

.scenery_2 {
  display: flex;
}
<div class="display">
<div class="scenery">
  <div class="scenery_1">
    <img src="https://s-media-cache-ak0.pinimg.com/736x/02/e1/52/02e1528600a592817fbfa1c67158c13f.jpg" alt="display">
    <img src="https://s-media-cache-ak0.pinimg.com/736x/02/e1/52/02e1528600a592817fbfa1c67158c13f.jpg" alt="display">
  </div>
  <div class="scenery_2">
    <img src="https://s-media-cache-ak0.pinimg.com/736x/02/e1/52/02e1528600a592817fbfa1c67158c13f.jpg" alt="display">
    <img src="https://s-media-cache-ak0.pinimg.com/736x/02/e1/52/02e1528600a592817fbfa1c67158c13f.jpg" alt="display">
    <img src="https://s-media-cache-ak0.pinimg.com/736x/02/e1/52/02e1528600a592817fbfa1c67158c13f.jpg" alt="display">
  </div>
</div>
</div>
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701

1 Answers1

0

I'm not sure why you're using display: flex, but this works:

.display {
  min-width: 500px;
  max-width: 100%;
  display: block; /* Add this, remove everything else*/
}
<div class="display">
  <div class="scenery">
    <div class="scenery_1">
      <img src="https://s-media-cache-ak0.pinimg.com/736x/02/e1/52/02e1528600a592817fbfa1c67158c13f.jpg" alt="display">
      <img src="https://s-media-cache-ak0.pinimg.com/736x/02/e1/52/02e1528600a592817fbfa1c67158c13f.jpg" alt="display">
    </div>
    <div class="scenery_2">
      <img src="https://s-media-cache-ak0.pinimg.com/736x/02/e1/52/02e1528600a592817fbfa1c67158c13f.jpg" alt="display">
      <img src="https://s-media-cache-ak0.pinimg.com/736x/02/e1/52/02e1528600a592817fbfa1c67158c13f.jpg" alt="display">
      <img src="https://s-media-cache-ak0.pinimg.com/736x/02/e1/52/02e1528600a592817fbfa1c67158c13f.jpg" alt="display">
    </div>
  </div>
</div>
Sreetam Das
  • 3,226
  • 2
  • 22
  • 36