I have a div container with two subcontainers. The parent div should have a full height (from the top to the bottom of the screen). The first sub container should always be in the left center of that parent container. The second sub container should always be at the right bottom of that parent container.
First of all I tried to solve it using absolute positions
html,
body {
height: 100%;
}
#first {
position: absolute;
top: 50%;
}
#second {
position: absolute;
bottom: 0;
right: 0;
}
<div>
<div id="first">
this is always on the left center of the screen
</div>
<div id="second">
this is always on the right bottom of the screen
</div>
</div>
I thought about avoiding absolute positions. Is there a way using flexbox/grid for this? I started with this
html,
body {
height: 100%;
}
#parent {
height: 100%;
display: flex;
}
#first {
align-self: center;
}
#second {
align-self: flex-end;
display: flex;
justify-content: flex-end;
}
<div id="parent">
<div id="first">
this is always on the left center of the screen
</div>
<div id="second">
<div>this is always on the right bottom of the screen</div>
</div>
</div>
as you can see the first subcontainer seems to be fine. The second one is at the bottom of the container which looks good. But the content is not at the right bottom corner (you might have to click "Full page" to see it). Does someone know how to fix it? Maybe this snippet can be simplified?
