My header is cutting off my background image. How to fix it?
*{
margin:0;
padding: 0;
list-style: none;
text-decoration: none;
font-family: 'Times New Roman', Times, serif;
box-sizing: border-box;
}
body{
min-height: 100vh;
background: linear-gradient(#2b1055,#7597de);
}
header{
width: 100%;
height: 80px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 100px;
}
.logo{
font-size: 28px;
font-weight: bold;
color: #fefefe;
}
.hamburger{
display: none;
}
.nav-bar ul{
display: flex;
}
.nav-bar ul li a{
display: block;
color: #fefefe;
font-size: 20px;
padding: 10px 25px;
border-radius: 50px;
transition: 0.2s;
margin: 0.5px;
}
.nav-bar ul li a:hover{
color: #11101b;
background: #fefefe;
}
@media screen and (max-width:1320px) {
header{
padding: 0 50px;
}
}
@media screen and (max-width:1100px) {
header{
padding: 0 30px;
}
}
@media screen and (max-width:900px) {
.hamburger{
display: block;
cursor: pointer;
}
.hamburger .line{
width: 30px;
height: 3px;
background: #fefefe;
margin: 6px 0;
}
.nav-bar{
height: 0;
position: absolute;
top: 80px;
left: 0;
right: 0;
width: 100vw;
transition: 0.5s;
overflow: hidden;
}
.nav-bar.active{
height: 450px;
}
.nav-bar ul{
display: block;
width: fit-content;
margin: 80px auto 0 auto;
text-align: center;
transition: 0.5s;
opacity: 0;
}
.nav-bar.active ul{
opacity: 1;
}
}
section{
position: relative;
width: 100%;
height: 100vh;
padding: 100px;
}
section img{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
How to overlay the background in the header as you can see the header is cutting off the moon. I have started my coding journey please explain it in easy word… It would be more helpful if you can provide the solution thank you… Is there any particular property to this or it can be done simply and I just made some mistake on my code.
New contributor
Shubhradeep Biswas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2