JSFiddle - React, Tailwind, and code Playground
HTML
<div id="global-stripe"></div>
<div id="page-header-wrapper">
<div id="page-header">
<div class="col hd-left">
<ul>
<li><a href="zzz"><div class="hd-icon"></div></a>
</li>
</ul>
</div>
<div class="col hd-center">FooBar</div>
<div class="col hd-right"></div>
</div>
</div>
<div id="fake-body"></div>
CSS
* {
box-sizing: border-box;
}
body {
margin: 0;
}
#global-stripe {
background-color: #333;
height: 20px;
}
#page-header-wrapper {
height: 100px;
}
#page-header-wrapper .page-header-fixed {
position: fixed;
height: 60px;
top: 0;
}
#page-header {
height: 100px;
width: 100%;
border-bottom: 2px solid #ccc;
background-color: #eee;
overflow: hidden;
display: inline-block;
z-index: 9999;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-ms-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
#page-header li {
display: inline-block;
padding: 10px;
border: 1px solid #eee;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 5px;
}
#page-header li:hover {
border: 1px solid #ccc;
background-color: #ddd;
}
.hd-icon {
height:50px;
width: 50px;
border: 1px solid #000;
display: inline-block;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-ms-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
.col:last-of-type {
float: right;
text-align: right;
}
.hd-center {
font-size: 48px;
text-align: center;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-ms-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
.col {
width: 33.33%;
float: left;
}
.page-header-fixed li {
padding: 5px;
}
.page-header-fixed .hd-icon {
width: 25px;
height: 25px;
}
.page-header-fixed .hd-center {
font-size: 36px;
}
#fake-body {
height: 1000px;
}
JavaScript
$(function () {
var stripe_height = $("#global-stripe").height();
$(window).scroll(function () {
var scroll_top = $(window).scrollTop();
if (scroll_top > stripe_height) {
// make header fixed
$("#page-header").addClass("page-header-fixed");
} else if (scroll_top < stripe_height) {
// remove fixed header
$("#page-header").removeClass("page-header-fixed");
}
});
});