I want to align two elements in such a way, that one sticks to the top, and one to the bottom of the viewport. I'm trying to achieve this with flexbox, but don't want to use absolute positioning.
Whatever I tried, didnt work: I found this question on stock overflow, and tried to implement those answers - yet I still can't achieve the wanted result. Can anybody point me in the right direction, or explain what I did wrong?
Below is my html / css, here you can find the code snippets on jsbin, with different stuff i tried.
All of the other stackoverflow questions I found regarding this topic didn't work for me either - I really don't get why. Any help would be really appreciated.
<html>
<body>
<div class="top">
<p class="text">Top</p>
</div>
<div class="bottom">
<p class="text">Bottom</p>
</div>
</body>
</html>
body {
min-height: 100%;
display: flex;
flex-direction: column;
}
.top {
flex-grow: 1;
}
.bottom {
margin-top: auto;
}