I have a div
with some children:
heading 1
heading 2
Some
1. Style parent element: style="display:flex; flex-direction:column; flex:1;"
2. Style the element you want to stay at bottom: style="margin-top: auto;"
3. Done! Wow. That was easy.
Example:
<section style="display:flex; flex-wrap:wrap;"> // For demo, not necessary
<div style="display:flex; flex-direction:column; flex:1;"> // Parent element
<button style="margin-top: auto;"> I </button> // Target element
</div>
... 5 more identical divs, for demo ...
</section>
Demo: https://codepen.io/ferittuncer/pen/YzygpWX
When setting your display to flex, you could simply use the flex
property to mark which content can grow and which content cannot.
Flex property
div.content {
height: 300px;
display: flex;
flex-direction: column;
}
div.up {
flex: 1;
}
div.down {
flex: none;
}
<div class="content">
<div class="up">
<h1>heading 1</h1>
<h2>heading 2</h2>
<p>Some more or less text</p>
</div>
<div class="down">
<a href="/" class="button">Click me</a>
</div>
</div>