JSFiddle - React, Tailwind, and code Playground
HTML
<div id="heading">
<img class="head" id="mainImg" src="https://placehold.it/50x50" alt="Know Music">
<button class="head head2 font" href="" id="hb1">Guitar</button>
<button class="head head2 font" href="" id="hb2">Bass</button>
<button class="head head2 font" href="" id="hb3">Piano</button>
<button class="head head2 font" href="" id="hb4">Drums</button>
</div>
CSS
html,body{height:3000px;}
#heading {
z-index: 2;
position: fixed;
height: 30px;
border: none;
background-color: rgb(10, 22, 18, 0);
transition: 0.5s ease-in-out all;
}
.head {
display: inline;
float: left;
opacity: 1.0;
}
.head2 {
height: 30px;
width: auto;
padding-left: 5px;
padding-right: 5px;
text-align: center;
text-shadow: 1px 1px 3px #666666;
color: rgb(255, 255, 255);
font-size: 15px;
text-decoration: none;
border: none;
background: none;
}
.head2:hover {
color: rgb(255, 255, 255);
text-decoration: none;
background-color: rgb(0, 0, 0);
}
.font {
font-family: 'Raleway', sans-serif;
font-style: normal;
}
.change{
background-color: rgba(10,22,18,1);
}
JavaScript
$(window).scroll(function() {
if ($(window).scrollTop() >= 100) {
$("#heading").addClass(" change");
} else{
$("#heading").removeClass(" change");
}
});