I'm trying to do a responsive layout with css grid by getting two elements to overlap each other halfway. On wide screens they are in one row and overlapping horizontally, but on narrow screens they should be in one column and overlap vertically.
Here is an illustration of what I'm trying to achieve:
Is this behavior possible with css grid? Here is how far I got but now I'm stuck trying to get the vertical overlap.
.wrapper {
background: white;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(444px, 1fr));
}
.wrapper__red,
.wrapper__green {
align-self: center;
}
.wrapper__red {
z-index: 1;
background: red;
}
.wrapper__green {
justify-self: end;
height: 100%;
background: green;
}
<div class="wrapper">
<h1 class="wrapper__red">Title text goes here</h1>
<img class="wrapper__green" src="https://via.placeholder.com/200" />
</div>
z-index
. – Complice