Flex Nav Collapse Framework
A clean implementation focusing on the collapse button aesthetics and functionality
Smooth Transitions
The collapse button features smooth cubic-bezier transitions for a polished feel. Notice how the chevron rotates and the button scales on hover.
Precise Positioning
The button is absolutely positioned on the edge of the navigation, creating a seamless connection between the nav and content areas.
Visual Feedback
Hover states include color changes, shadow elevation, and subtle scaling. The active state provides immediate tactile feedback.
Icon Animation
The chevron icon smoothly rotates 180 degrees to indicate the collapsed/expanded state, providing clear visual communication.
State Persistence
The navigation state is saved to localStorage, maintaining user preference across sessions for a better experience.
Accessibility
The button includes proper ARIA labels and keyboard support, ensuring the interface is usable by everyone.
Layout Structure & Components
Fixed Header
.fixed-header- Main header container (56px height).header-container- Inner flex container.mobile-menu-toggle- Hamburger menu (mobile only).search-bar- Central search input.expand-user-drawer-button- User menu trigger
User Drawer
#userDrawer- Dropdown container.drawer-header- User info section.drawer-nav- Navigation items#drawerOverlay- Click-outside overlay
Flex Navigation
#flexNav- Main navigation sidebar.flex-nav-collapse-button- Collapse toggle.nav-menu- Navigation items container.nav-item- Individual nav links.collapsed- State class (80px width).mobile-open- State class for mobile off-canvas menu
Main Content
.app-container- Main flex container.main-content- Content area (1200px max).content-grid- Responsive card grid.content-card- Individual content cards
Key Features & Interactions
- Expanded: 260px width
- Collapsed: 80px width
- Mobile: Off-canvas slide-in
- Desktop: > 768px
- Mobile: ≤ 768px
- Content max-width: 1200px
toggleNav()- Nav collapsetoggleUserDrawer()- User menucloseUserDrawer()- Close drawer
Recent Changes
- Increased the
topoffset for the sticky right column to80pxto provide more space below the fixed header. - Made the right-hand column sticky using
position: sticky;so it remains in view on scroll. - Restructured the
.main-contentarea into a two-column layout (3/4 and 1/4 width) using CSS Grid. - Refactored JavaScript event handling by removing all inline
onclickattributes from HTML and centralizing them injs/script.js. This fixed the non-functional.flex-nav-collapse-button. - Updated the dark theme color palette in
style.cssto a monochrome, gunmetal grey scheme for a more modern look. - Increased
z-indexof.flex-navto90to ensure it appears above the main content. - Adjusted the
rightposition of.flex-nav-collapse-buttonto5pxfor better visibility. - Changed the
heightof.nav-headerto56px. - Modified
.flex-navto beposition: fixed; top: 56px; height: calc(100vh - 56px);for fixed desktop navigation, starting below the header. - Added
padding-top: 56px;to thebodyto prevent content from being hidden by the fixed header. - Updated
.main-contentto havemargin-left: var(--nav-width);(and--nav-collapsed-widthwhen collapsed) to accommodate the fixed navigation. - Implemented responsive design for mobile devices (
@media (max-width: 768px)):.mobile-menu-toggleis now displayed..flex-navis positioned off-canvas (left: calc(-1 * var(--nav-width));) and slides in with.mobile-openclass. On mobile,.flex-navnow starts fromtop: 0;and takesheight: 100vh;..flex-nav-collapse-buttonis hidden..main-contenthasmargin-left: 0;and adjusted padding.
- Reverted
.nav-headerpadding from0 15px;back to0 24px;. - Moved the
#my-layoutdiv to be inside the.main-contentarea and adjusted its internal padding. - Separated all CSS into a new file,
style.css, and linked it in the HTML header. - Updated the stylesheet link from
href="style.css"tohref="css/style.css". - Separated JavaScript into a new file,
js/script.js, and linked it in the HTML.