I'm trying to make a grid responsive. It's working so far but on thing still bothers me. If I'm setting a grid item's span property to start at the second column from the left, the grid breaks on window resize.
The expected and the actual result:
So there are two grid containers with almost the same CSS properties. The top grid's items should be at the very right of the grid container and the bottom grid's items should be at the very left of the grid container.
The bottom grid and its items scale as expected into a single column, however the top grid shows two (even different sized) columns instead of the expected single column. So its item spans only over one column.
The two grid containers and grid items have almost the same CSS properties:
.-has-columns {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(30rem, 1fr));
}
// top item
.-column-item--right {
grid-column: 2 / -1;
background: green;
}
// bottom item
.-column-item--left {
grid-column: 1 / -2;
background: lightblue;
}
article,
figure,
img {
width: 100%;
}
The HTML:
// top container
<article class="-has-columns">
<div class="-column-item--right">
<figure>
<img>
</figure>
</div>
</article>
// bottom container
<article class="-has-columns">
<div class="-column-item--left">
<p>
<p>
<p>
</div>
</article>
Thanks for any tips!