Так?:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="header"><p>Меню</p></div>
</body>
<style>
.header{
width: 100%;
height: 80px;
transition-duration: 1s;
z-index: 2;
position: fixed;
background: rgba(0, 0, 0, 0);
}
body{
min-height: 2000px;
}
</style>
<script>
let header = document.querySelector(".header")
window.onscroll = function(){
if(window.scrollY > 100){
header.style.background = "#000"
}
else{
header.style.background = "rgba(0, 0, 0, 0)"
}
}
</script>
</html>