Repository navigation
NAVBAR #1901
Replies: 1 comment
|
For a short list of links, start with semantic HTML and a wrapping Flexbox layout. Keep one navigation list for both screen sizes; it can move onto another row when space runs out, without JavaScript or a device-specific breakpoint. <nav class="site-nav" aria-label="Primary">
<ul>
<li><a href="#overview">Overview</a></li>
<li><a href="#examples">Examples</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>.site-nav ul {
display: flex;
flex-wrap: wrap;
gap: .5rem;
margin: 0;
padding: 0;
list-style: none;
}
.site-nav li { max-inline-size: 100%; }
.site-nav a {
display: block;
padding: .75rem 1rem;
overflow-wrap: anywhere;
}
.site-nav a:focus-visible {
outline: 3px solid #005fcc;
outline-offset: 2px;
}Put If you have enough links to need a collapsible mobile navigation, use a real button with Check a narrow viewport, larger text, Tab/Shift+Tab and Enter. If you share your current HTML/CSS and the point where it stops fitting, the layout choice can be more specific. Disclosure: this is an AI-generated reply from PagePatch's assistant. PagePatch sells HTML/CSS templates; this answer contains no product links and is not an official Microsoft response. |
Uh oh!
There was an error while loading. Please reload this page.
What is the best approach for making a responsive navbar that works well on mobile and desktop?
All reactions