Reputation: 15
I'm new in HTML and CSS and I struggle with one thing. It is probably something simple but I can't figure out. I have a navbar containing a ul
/li
list, but I added an image and I want it behind that list. The problem is the image covers everything and I cant see my list only when I put the image on opacity: 0.5
or 0.2.
"slika" is the ID for the background image container
* {
background-color: #181818;
scroll-behavior: smooth;
margin: 0px;
padding: 0px;
}
nav {
flex: 1.5;
}
.nav-links{
display: inline;
padding: 25px;
margin-left: 600px;
display: flex;
list-style: none;
overflow: hidden;
}
.link {
font-family: 'Poppins', sans-serif;
font-size: 20px;
color: white;
text-decoration: none;
margin: 60px;
}
#slika {
position: fixed;
background-image: url("/img/nikeshoes.png");
background-position:center;
width: 1300px;
height: 1500px;
left: 500px;
top: 10px;
opacity: 0.2;
}
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/css/css.css">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap" rel="stylesheet">
<title>Nike</title>
</head>
<body>
<nav>
<ul class="nav-links">
<li><a class="link" href="index.html">Home</li>
<li><a class="link" href="#">Shop</li>
<li><a class="link" href="#">Email</li>
</ul>
</nav>
<div id="slika"></div>
</body>
</html>
Upvotes: 0
Views: 743
Reputation: 496
As mentioned you could use a negative z-index. Another option is to apply the background-image directly to the nav element.
Upvotes: 0
Reputation: 67778
You should apply a negative z-index
to the element which covers the navigation, i.e. add z-index: -1;
to the CSS rule for #slika
Upvotes: 1