I'm having trouble aligning the links in my navigation bar to display 4 links evenly on each line when the screen size is reduced.
Here's how it looks at full width:
However, when I shrink the window, each link gets pushed down individually, resulting in a messy layout (see image below).
Below is the code snippet:
nav {
background-color: #d6d6d6;
}
nav ul {
margin: 0 0 2% 0;
padding: 10px;
}
nav ul li {
display: inline;
margin: 0;
width: 25%;
}
nav ul li a {
text-decoration: none;
}
nav ul li a:not(:last-child) {
border-right: 1px solid #919191;
padding: 0 10px 0 10px;
}
<nav>
<ul>
<li>
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Sample link 1</a>
<a href="#">Sample link 2</a>
<a href="#">Sample link 3</a>
<a href="#">Sample link 4</a>
<a href="#">Portfolio</a>
<a href="#">Contact</a>
</li>
</ul>
</nav>