I'm new to html/css, and I want to using only HTML/CSS to make navbar always on top when scroll down becoming transparents. it's possible? right now it's make me crazy I can't make background image under my navbar. where should I change the CSS part?
here is what I expect to become
[a link] https://frankyeah.github.io/Front-Enter/index.html
What I have done is the following
HTML:
<nav>
<div>
<a href="" class="logo"><img src="./image/FE_logo-4.png"></a>
Logo
</div>
<div class="navlist">
<a href="">explore</a>
<a href="">Skill</a>
<a href="">login</a>
</div>
<div>
<a href="" class="search"><img src="./image/FE_search_green.png">
</a>
</div>
</nav>
<main>
<div class="mainview"></div>
<div class="mainview2"></div>
<div></div>
<div></div>
<div></div>
</main>
CSS:
<style>
nav{
display: flex;
justify-content: space-between;
flex-flow:row nowrap;
position: fixed;
width:100%;
background-color: white;
opacity:0.7;
z-index:999 ;
margin: 0 auto;
padding: 0;
}
.logo>img{
display: flex;
flex-flow:row nowrap;
width:50%;
margin-top:5%;
margin-left:20%;
}
.navlist{
display: flex;
flex-flow:row nowrap;
width:40%;
justify-content: space-evenly;
margin-top:2.5%;
margin-left:40%;
font-family:"arial";
}
a:hover{
color: #66FFFF;
}
div a{
text-decoration: none;
color:#AAAAAA;
}
.search>img {
display: flex;
flex-flow:row nowrap;
margin:30px 50px;
width:20%;
}
.mainview{
overflow: hidden;
background-image:url("../image/key-visual.jpg");
background-repeat:no-repeat;
background-attachment:scroll;
background-size: cover;
widows: 100%;
height: 100%;
padding-top: 50%;
}
.mainview2{
background-image:url("../image/second-img.jpg");
background-attachment:scroll;
background-position:top left;
background-repeat:no-repeat;
background-size: cover;
widows: 100%;
height: 100%;
padding-top: 50%;
margin: 0 0;
}
</style>
I expect the background image will under my navbar and when scrolling down navbar will be transparents, but something going wrong.