Designing Responsive SharePoint 2010 Top NavigationSharePoint 2010 was built in an era when desktop screens dominated. Still, many organizations continue to run SharePoint 2010 sites and need them to work acceptably on tablets and phones. Building a responsive top navigation for SharePoint 2010 requires a combination of careful markup, CSS, JavaScript, and progressive enhancement. This article walks through principles, step-by-step implementation options, accessibility considerations, performance tips, and troubleshooting strategies so your top navigation remains usable across screen sizes and devices.
Why responsive top navigation matters
- Improved usability on small screens. Standard horizontal menus break or overflow on narrow viewports, making key links hard to reach.
- Consistent experience across devices. A responsive top nav helps mobile and desktop users find content quickly without separate mobile sites.
- Future-proofing. Even if full migration isn’t possible, incremental improvements on legacy SharePoint improve overall user satisfaction.
Constraints in SharePoint 2010
- Server-side rendering uses ASP.NET master pages (often v4.master) and SharePoint controls like the AspMenu (SPNavigation, QuickLaunch, etc.).
- Out-of-the-box navigation controls emit markup and CSS that can be hard to override without custom master pages or additional scripts.
- No built-in responsive framework (Bootstrap, etc.) is included by default — you’ll add that client-side.
- Customizing master pages and adding scripts requires farm or site collection administrator privileges and appropriate testing.
Core design approaches
-
Progressive enhancement
- Keep default SharePoint menu for environments where scripts/CSS may be blocked.
- Add CSS and JavaScript that enhance layout and behavior for modern browsers.
-
CSS-first layout
- Use flexible containers, media queries, and overflow handling so the menu adapts without relying solely on JS.
-
JavaScript behavioral enhancements
- Use JS to toggle a mobile-friendly “hamburger” menu, collapse long lists, and add touch-friendly interactions.
-
Accessibility and keyboard support
- Ensure ARIA attributes and keyboard navigation remain functional. Preserve focus order and use semantic elements.
Example implementation overview
The solution below uses:
- A small CSS reset for the navigation area.
- Media queries to switch between full horizontal layout and a collapsed mobile menu.
- A minimal JavaScript toggle to open/close the mobile menu.
- Minimal changes to the master page: wrapping the existing top navigation in a container and including custom CSS/JS files.
Note: Replace IDs and CSS selectors to match your master page markup (for example, the top nav may be within #s4-titlerow, #DeltaTopNavigation, or custom placeholders).
1) Master page adjustments
Wrap the SharePoint top navigation control in a container. In your custom master page (make a copy of v4.master and edit), locate the top navigation render (often an AspMenu or SharePoint:DelegateControl for TopNavigationDataSource) and wrap it:
<!-- Put this around the Top Navigation control --> <div id="responsiveTopNav"> <!-- existing SharePoint Top Navigation control goes here --> <asp:ContentPlaceHolder id="PlaceHolderTopNav" runat="server"> <!-- Example: existing SharePoint markup stays unchanged --> </asp:ContentPlaceHolder> <button id="navToggle" aria-expanded="false" aria-controls="navMenu" aria-label="Toggle navigation"> ☰ <!-- hamburger icon --> </button> </div>
Keep the existing server controls intact — this wrapper simply gives you an outer hook for CSS/JS.
2) CSS: layout and responsiveness
Add a CSS file (e.g., responsive-topnav.css) and include it in the master page after core SharePoint CSS so your rules override defaults.
Key ideas:
- Use flexbox for the horizontal layout (works in IE10+; SharePoint 2010 commonly runs on IE8/9 in legacy environments — if IE8/9 support is required, use float-based fallbacks).
- Hide the toggle by default on wide screens; show it on small screens.
- Collapse the navigation into a vertical list on small screens.
Example CSS (adjust selectors to match your markup):
/* Container basics */ #responsiveTopNav { position: relative; background: #f8f8f8; border-bottom: 1px solid #ddd; font-family: "Segoe UI", Tahoma, Arial, sans-serif; } /* Hide default list-style and set up flex layout for the nav UL */ #responsiveTopNav .static > ul { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; } /* Individual nav items */ #responsiveTopNav .static > ul > li { margin: 0; padding: 0 12px; white-space: nowrap; } /* Links */ #responsiveTopNav .static a { display: inline-block; padding: 12px 6px; color: #333; text-decoration: none; } /* Toggle button (hidden on desktop) */ #navToggle { display: none; position: absolute; right: 8px; top: 8px; background: transparent; border: none; font-size: 22px; } /* Mobile styles */ @media (max-width: 768px) { #navToggle { display: block; } #responsiveTopNav .static > ul { display: none; /* hidden until toggled */ flex-direction: column; width: 100%; } #responsiveTopNav .static > ul.open { display: flex; } #responsiveTopNav .static > ul > li { padding: 10px 16px; border-top: 1px solid #e5e5e5; } }
Notes:
- SharePoint often wraps menu items with classes like .static and .dynamic; inspect your page’s markup and adjust selectors.
- If you need to support IE8/9, replace flexbox with inline-block or floats and adjust spacing.
3) JavaScript: toggle and enhancements
Add a small script to toggle the menu on mobile and handle aria-expanded state and simple keyboard interactions.
Example script (place in a file responsive-topnav.js and include it near the end of the page):
(function(){ var toggle = document.getElementById('navToggle'); if (!toggle) return; // Find the UL that contains top nav links; adjust selector for your markup var navUL = document.querySelector('#responsiveTopNav .static > ul'); if (!navUL) return; toggle.addEventListener('click', function(){ var expanded = this.getAttribute('aria-expanded') === 'true'; this.setAttribute('aria-expanded', !expanded); if (!expanded) { navUL.classList.add('open'); } else { navUL.classList.remove('open'); } }); // Close menu on outside click (mobile) document.addEventListener('click', function(e){ if (!navUL.classList.contains('open')) return; if (!document.getElementById('responsiveTopNav').contains(e.target)) { navUL.classList.remove('open'); toggle.setAttribute('aria-expanded', 'false'); } }); // Keyboard support: close on ESC document.addEventListener('keydown', function(e){ if (e.key === 'Escape' || e.keyCode === 27) { if (navUL.classList.contains('open')) { navUL.classList.remove('open'); toggle.setAttribute('aria-expanded', 'false'); toggle.focus(); } } }); })();
If your users run old IE versions, use attachEvent and className toggling or include a small shim.
4) Handling multi-level menus and flyouts
SharePoint top navigation often includes flyouts (submenus). For responsive design:
- On desktop, keep hover or focus-based flyouts as-is.
- On mobile, convert flyouts into accordion-style expandable sections. Replace hover with click/tap to expand sublists.
Sample pattern:
- Add a button or expand icon next to top-level items that have children.
- Toggle a CSS class to show/hide the nested UL on small screens.
- Ensure nested items are indented and touch targets are large enough.
Example CSS for nested accordions:
@media (max-width: 768px) { #responsiveTopNav .static ul ul { display: none; padding-left: 12px; } #responsiveTopNav .static .hasChildren > button.expand { display: inline-block; margin-left: 6px; background: none; border: none; } #responsiveTopNav .static .hasChildren.open > ul { display: block; } }
And JS: detect list items with nested ULs, add expand buttons, and toggle on click.
5) Accessibility considerations
- Use semantic elements where possible. If you keep SharePoint’s rendered HTML, add ARIA attributes:
- role=“navigation” on the container.
- aria-expanded on toggles.
- aria-controls pointing to the nav UL’s id.
- Ensure focus order: the toggle should be reachable by keyboard and clearly labeled (aria-label).
- For flyouts, manage aria-hidden on hidden submenus and update it when they are opened.
- Provide visible focus styles for keyboard users.
Example additions:
<nav id="responsiveTopNav" role="navigation" aria-label="Top Navigation"> ... </nav>
6) Performance tips
- Minify and combine CSS/JS files to reduce HTTP requests.
- Host static assets on the same SharePoint (or a CDN if permitted) and use caching headers.
- Avoid heavy JS frameworks; use lightweight vanilla JS or an existing small library already present on your site.
- Test on slow networks/devices (browser devtools throttling).
7) Testing and fallback
- Test in target browsers (IE8/9 if required), Chrome, Edge, Safari, Firefox, and on real mobile devices.
- Verify keyboard-only navigation and screen-reader behavior (NVDA, JAWS, VoiceOver).
- Provide graceful fallback: if JS is disabled, the menu should remain usable (even if not mobile-optimized). Keep base markup intact.
8) Troubleshooting common issues
- Menu items still wrapping: check padding/margins and white-space; consider reducing padding or hiding less important links behind a “More” dropdown.
- Flyouts not working after CSS changes: SharePoint uses scripts for dynamic menus — ensure you aren’t breaking required classes or removing necessary SharePoint scripts.
- CSS specificity: SharePoint CSS can be specific. Use carefully targeted selectors or include your CSS after SharePoint CSS. Avoid !important except as last resort.
- Caching delays after deploying new master page: clear browser/SharePoint object cache, and perform an IIS reset if on-prem and changes don’t appear.
Alternative: Use a front-end framework
If you can add a framework like Bootstrap (even just its grid and nav components), you can leverage built-in responsive nav patterns. Steps:
- Add Bootstrap CSS and a small JS file for toggling (or implement your own toggle).
- Adapt SharePoint markup to Bootstrap’s nav structure or wrap the SharePoint output and map classes with JS.
This speeds development but increases asset load and may require additional styling to match SharePoint look-and-feel.
Example: compact checklist for rollout
- [ ] Create a copy of v4.master and work in a development farm/site collection.
- [ ] Wrap top navigation in a responsive container and add toggle button.
- [ ] Add responsive CSS and mobile-specific rules.
- [ ] Add JS toggle and accessibility attributes.
- [ ] Implement accordion behavior for submenus on mobile.
- [ ] Test across browsers, devices, and assistive tech.
- [ ] Minify and deploy assets to production with caching.
Designing a responsive top navigation for SharePoint 2010 is largely about augmenting existing markup with modern CSS and small, focused JavaScript while respecting accessibility and legacy browser constraints. With careful progressive enhancement you can make the top nav functional and pleasant across devices without a full platform upgrade.
Leave a Reply