I have created a navigation bar (ul
) with diagonal left and right borders.
I am facing difficulty in ensuring that the :hover
effect fills the entire li
.
Is there a way to achieve this or should I consider changing my approach?
section ul {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: left;
list-style-type: none;
margin: .5em 1em;
}
li {
margin: 0;
border-radius: 1px;
position: relative;
padding: 0.3em 0.8em;
cursor: pointer;
}
li:nth-child(2n+1)::before {
content: "";
border-right: 2px solid black;
transform: rotate(20deg);
display: block;
position: absolute;
top: -2px;
left: -5px;
width: 2px;
height: 120%;
}
li:nth-child(2n)::after {
content: "";
border-right: 2px solid black;
transform: rotate(-20deg);
display: block;
position: absolute;
top: -2px;
left: -5px;
width: 2px;
height: 120%;
}
li:hover {
background-color: black;
color: white;
}
<section>
<ul>
<li><a>Link 1</a></li>
<li><a>Link 2</a></li>
<li><a>Link 3</a></li>
<li><a>Link 4</a></li>
</ul>
</section>