0

I have a layout with a centered content column where I want an image to break out on the right side to the edge of the browser. Without an image it works fine, but with an image and a breakpoint with fixed values for the cols 2 and 3, the image takes too much space.

.copy{
  grid-row-start: 1;
  grid-column-start: 2;
  grid-column-end: 3;
}

.img{
  grid-row-start: 1;
  grid-column-start: 3;
  grid-column-end: 5;
  width: 100%;
}

.grid-container-centered {
  wodth: 100%;
  display: grid;
  grid-template-columns: 5% 45% 45% 5%;
}

// now it starts breaking with an image
@media (min-width: 1280px) {
  .grid-container-centered {
    grid-template-columns: auto 576px 576px auto; // 576px => 1280*0.9 / 2
  }
}

enter image description here

I have created a demo there https://codepen.io/destroy90210/pen/OJbJQby?editors=1100

Solution Instead of "auto" it must be "1fr"

grid-template-columns: 1fr 576px 576px 1fr;
Gregor Voinov
  • 2,203
  • 7
  • 34
  • 52
  • 2
    1fr instead of auto if you expect to have the same space on each side. different `auto` aren't equal but will behave differently and will have different sizes – Temani Afif Jan 30 '21 at 08:27
  • thank's it works :) I was thinking auto is filling automatic the remaining space :) – Gregor Voinov Jan 30 '21 at 08:35

0 Answers0