I am trying to keep a fixed element visible at the top of the page while also having content with varying heights. Here is the CSS code for the fixed element:
div.topfloat
{
position: fixed;
top: 0;
width: 100%;
}
The issue I'm facing is that the fixed element overlaps with the content, and adjusting the "top-padding" property based on the fixed element's height doesn't work well.
I need a solution like this:
div.content
{
padding-top: [height of topfloat-element];
}
Here is the simple HTML setup:
<div class=topfloat>variable height</div>
<div class=contents>please don't overlap me</div>
Is there any way to resolve this without resorting to Javascript?