hey guys, is there anyway i can set my menu bar to be opaque in top:0 position and then go transparent when scrolled down ? I also
apoligize for including all these mess but i thought knowing other color properties might be necessary for solution.here’s my code :
<html>
<head>
<title>...</title>
<style>
* {box-sizing: border-box}
body,html{
background-color:purple;
margin:0;
padding:0;
height:100%;
font-size:20px;
font-family:helvetica,arial;
}
.menu {
min-height:3em;
position:sticky;
top:0;
z-index:1;}
.wrapper{
max-width:1200px;
margin:auto;}
.content{
display:flex;
flex-wrap:wrap;
flex-direction:row;
background-color:#efe8ff;
min-height:100%;
margin:0;
padding:1em;
justify-content:space-evenly;}
.child{
display:flex;
flex-flow:column wrap;
width: 20em;
height:30em;
border:1px solid black;
margin:1em;
}
.tablink{line-height:3em;
color:#D860E6;
float:left;
width:50%;
border:none;
outline:none;
font-size:22px;
-webkit-transition: background-color 0.2s ease;
-moz-transition: background-color 0.2s ease;
-o-transition: background-color 0.2s ease;
transition: background-color 0.2s ease;}
.tablink:hover{
color:#8631b7;
font-weight:bolder;}
.footer {
min-height:5em;
background-color:#1c1c1c;}
#a{background-color:#efe8ff;}
#b{background-color:#e8eeff;}
</style>
</head>
<body>
<div class="menu">
<button class="tablink" onclick="show('a',this,'rgb(239, 232, 255,0.9)')">A</button>
<button class="tablink" id="default" onclick="show('b',this,'rgb(232, 238, 255,0.9)')">B</button>
</div>
<div class="wrapper">
<div id="a" class="content">......</div>
<div id="b" class="content">
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
</div>
<div class="footer"></div>
</div>
<script>
function show(page,elmnt,color){
// Hide all elements with class="content" by default */
var i,contents,tablinks;
contents=document.getElementsByClassName("content");
for(i=0;i<contents.length;i++){
contents[i].style.display="none";}
// Remove the background color of all tablinks/buttons
tablinks=document.getElementsByClassName("tablink");
for(i=0;i<tablinks.length;i++){
tablinks[i].style.backgroundColor="rgb(40, 15, 218,0.9)";}
// Show the specific tab content
document.getElementById(page).style.display="flex";
// Add the specific color to the button used to open the tab content
elmnt.style.backgroundColor=color;}
// Get the element with id="default" and click on it
document.getElementById("default").click();
</script>
</body>
</html>