Hi, today I was trying to achieve this navigation bar:
It took me a while though. I know there might be several ways to achieve this, so I’d like anyone else to write they own approach.
I’m sharing my way below:
ul {
background-color:red;
display:flex;
list-style-type:none;
justify-content:flex-end;
}
ul > li {
padding:1rem;
}
ul > li:hover{
background-color:rgba(0,120, 20, 0.7);
}
ul>li:first-child{
margin-right:auto;
}
The issue was I wasn’t aware of how flexbox redefines margins, and now I know that trick of margin:auto
works here rather well.