The header section is fixed height, but the header content may change. We would like to content of the header to be vertically aligned to the bottom of the header section, so the last line of text “sticks” to the bottom of the header section.
So if there is only one line of text it would be like:
Header title
header content (resulting in one line)
And if there were three lines:
Header title
header content (which is so much stuff that it perfectly spans over three lines)
/* creates a new stacking context on the header */ #header { position: relative; } /* positions header-content at the bottom of header's context */ #header-content { position: absolute; bottom: 0; }
you need identify the header-content to make this work.
The solution just takes one <div>, which we call the “aligner”:
html code
<div class="bottom_aligner"></div> ... Your content here ...
This trick works by creating a tall, skinny div, which pushes the text baseline to the bottom of the container.
Example Program for HTML :
html code
<body> <div class="outer-container"> <div class="top-section"> This text <br> is on top. </div> <div class="bottom-section"> <div class="bottom-aligner"></div> <div class="bottom-content"> I like it here <br> at the bottom. </div> </div> </div> </body>
Wikitechy Founder, Author, International Speaker, and Job Consultant. My role as the CEO of Wikitechy, I help businesses build their next generation digital platforms and help with their product innovation and growth strategy. I'm a frequent speaker at tech conferences and events.