JSFiddle - React, Tailwind, and code Playground
by inkc
HTML
<div class="page">
<header>The header bar</header>
<div class="content">the content here </div>
</div>
<div class="before-header">This is dynamically created</div>
CSS
.page {
background:#f8f8f8;
height:900px;
/*margin-top: 100px;*/
}
.before-header {
position:fixed;
top:0;
background:#09f;
height:360px;
width:100%;
z-index:30000;
}
header {
position:fixed;
top:0px;
background:#f90;
height:30px;
width:100%;
}
JavaScript
var finder = document.getElementsByClassName("before-header")[0];
var findrheight = finder.clientHeight;
var main = document.getElementsByTagName("header")[0];
main.style["margin-top"] = findrheight+"px";