I designed a navigation bar with the following CSS structure
nav {
text-align: center;
}
nav > ul {
list-style: none;
padding: 0;
margin: 8px auto;
}
nav > ul > li {
display: inline-block;
padding: 10px;
width: 200px;
text-align: center;
box-sizing: border-box;
border-right: 1px solid;
}
nav > ul > li:last-child {
border-right: 0px none;
}
nav a {
font-size: 130%;
}
<nav>
<ul>
<li><a href="url">link one</a>
<li><a href="secondurl">link two</a>
...
</ul>
</nav>
The li:last-child
part helps enhance its appearance. However, I encounter an issue when the navigation bar collapses (like on smaller screens or browsers). I want to remove those borders before they break into a new line. Is there a way in plain CSS to achieve this? If not, what would be a JavaScript solution for this scenario?
I explored the MDN Selector list, but it seems like no pseudo-class selector specifically caters to this requirement. I thought about using media queries for different screen sizes to dynamically remove the border, but that approach seems more like a workaround. Am I overlooking a more HTML-centric solution to address this concern?