I’m building another website and the background is a watercolor type painting and I wanted to make it where every nav button had an image of a watercolor splatter behind it. I’ve been trying to figure it out but nothing has worked.
Here is my current attempt but nothing I’ve tried has worked yet:
nav {
display: flex;
padding: 2% 6%;
justify-content: space-between;
align-items: right;
}
.nav-links {
flex: 1;
text-align: right;
}
.nav-links ul {}
.nav-links ul li a {
color: black;
text-decoration: none;
cursor: pointer;
}
.nav-links ul li {
list-style: none;
display: inline-block;
padding: 8px 12px;
position: relative;
background-image: url(https://assets.onecompiler.app/42tzva7s5/42wnuqh5j/water%20drop.png);
background-position: relative;
}
<nav>
<div class="nav-links">
<ul>
<li><a href="">LORUM</a></li>
<li><a href="">LORUM</a></li>
<li><a href="">LORUM</a></li>
<li><a href="">LORUM</a></li>
<li><a href="">LORUM</a></li>
</ul>
</div>
</nav>
3
Answers
Give this CSS a shot:
Using a pseudo-element (
::before
in this case) is a good way to add custom elements to each item in a list, or every child divThis property should work in any element. Looks like the only thing missing is the url enclosed in quotes.
I hope the following code snippet is your desired result. You might want to change the
background-size
property to eithercover
orcontain
, depending on your preference. The snippet here usescontain
.