A responsive website footer in pure CSS and vanilla JavaScript: four link columns on desktop that turn into collapsible accordion sections on phones, a region and currency select, and a smooth back to top button. This mobile footer menu example fits online stores, brand sites and any site with many footer links.
How it works
The root .maf-root contains a short .maf-strip (the end of a page section) and footer.maf-footer. .maf-top holds the brand block (logo, description, contact address, shipping note) and nav.maf-cols with four .maf-col columns.
Every column heading contains two versions of the title: .maf-title (plain text for wide screens) and button.maf-toggle with aria-expanded and aria-controls (for phones). On load the script sets hidden on every .maf-list whose button is collapsed and toggles both values on click. From 768px the CSS hides the buttons, shows .maf-title and forces .maf-list[hidden] to display: block, so all links are visible on desktop without extra JavaScript. Without JavaScript the lists simply stay open.
.maf-select changes the region. The REGIONS object in script.js maps each option value to a support phone number, a tel: link and a free shipping threshold, which update .maf-phone-text, .maf-phone and .maf-shipping-text. .maf-top-btn scrolls to the top with behavior: 'smooth' and moves focus to the element named in data-maf-target. The copyright year in .maf-year is computed in JavaScript.
Customization
--maf-accentand--maf-accent-darkon.maf-root: the teal of the logo, icons, back to top button and focus rings.--maf-radius: corner radius of buttons, the select, social icons and the shipping note (8px by default).--maf-bg,--maf-page,--maf-text,--maf-mutedand--maf-line: footer background, strip background, text colors and dividers.REGIONSinscript.js: add a key withname,currency,phone,telandfree, then add a matchingoptionto.maf-select.data-maf-targeton.maf-top-btn: the id of the heading that receives focus after scrolling up.aria-expanded="true"on a.maf-toggle: that section starts open on phones.- The
768pxmedia query instyle.css: the width where accordions become columns.
Use cases
- Online stores: shop, help and store links stay compact on phones
- International shops: visitors switch region and see local support and shipping terms
- Long pages: the back to top button returns readers to the start
- Brand and product sites: contact details sit next to the link columns
Accessibility
The links sit in a nav with aria-label="Footer", column titles are h2 headings, and accordion buttons report their state with aria-expanded. Region changes and the jump to the top are announced in a polite live region (.maf-live). Tap targets are at least 40px, social icons carry hidden names in .maf-sr, focus is visible in teal, and smooth scrolling and chevron rotation turn off with prefers-reduced-motion: reduce.
Usage notes
The select only updates the footer; connect it to your store's currency setting in the change handler.