When it comes to headers, we often use position: fixed;
to keep the header fixed at the top of the page. But what if we need two headers - one main header and one smaller header for secondary links? After some research, I discovered a tip that suggests using position: relative;
in the parent element style (the main header) and position: absolute; bottom: 0;
in the child element style (the div). However, this results in the main header becoming unstuck from the top. One solution could be to add
margin-top: (height of the header);
to the div
stylesheet. This may work on your current screen resolution, but on another device, where the height of the main header varies, the second header (div) might end up being positioned too low.
https://i.sstatic.net/Nzmmb.png
One possible workaround is shown below, but even then, the size will vary depending on the device's resolution:
https://i.sstatic.net/XMhrD.png
So, my question remains - How can we properly affix the div
element to the bottom of the header
element?