Version 0.2.1 File types HTML, CSS, SCSS, JavaScript Libraries/Fonts Google Fonts, Fontawesome 5, Bourbon, Bootstrap 4*

* Bootstrap mixins are only used during SCSS preprocessing not grid system

Installation

Clone this repository to your folder

git clone https://github.com/cookforweb/full-page-css-menu.git

Go into the newly created directory

cd full-page-css-menu

Install depedencies

npm install

Start editing index.html files using your own links and menu structure

CSS Menu structure

The menu has to two main elements. The trigger element (the one that opens the menu) and the wrapper which contains all the menu links and structure. Menu content has 3 parts. First one is the header which contains the title and the close button, second is the .cfw-menu-content where all the links have been placed and the last one is the footer which can host a small text or link.

<!-- Menu trigger element. Can be placed anywhere you want --> <div id="trigger-menu" class="trigger-menu"> <i class="fas fa-ellipsis-h"></i> </div> <!-- Here is where menu content is starting --> <div class="cfw-menu-wrapper"> <div class="inside"> <div class="cfw-menu-content"> <div class="cfw-menu-header"> <h2 class="cfw-menu-title">Site Navigation</h2> <div class="cfw-menu-close"> <i class="fas fa-times"></i> </div> </div> <div class="cfw-menu-body"> ... </div> <div class="cfw-menu-footer"> This is the menu footer </div> </div> <div class="cfw-menu-overlay"></div> </div> </div>

Above is the HTML markup with the .cfw-menu-content div empty. We will place some links there on the next step.

Menu Links

As we mentioned before .cfw-menu-content is the div where the magic happens. The most important element because holds all the content a menu must contain (the links to rest of the site, or extenral links).

The logic here is all the links to be visible once the menu is open, instead of creating dropdown menus and hover events in order the user to discover a link.

Content Structure

Our menu contains 6 main (with some modication the number can be changed) ul elements and each one contains one submenu with 7 links maximum (this number can be also modified). As a result this is the HTML markup after adding the submenus:

<!-- Menu trigger element. Can be placed anywhere you want --> <div id="trigger-menu" class="trigger-menu"> <i class="fas fa-ellipsis-h"></i> </div> <!-- Here is where menu content is starting --> <div class="cfw-menu-wrapper"> <div class="inside"> <div class="cfw-menu-content"> <div class="cfw-menu-header"> <h2 class="cfw-menu-title">Site Navigation</h2> <div class="cfw-menu-close"> <i class="fas fa-times"></i> </div> </div> <div class="cfw-menu-body"> <div class="cfw-menu-item cfw-menu-item-1"> <h3 class="item-title"><a href="#3">Getting Started</a></h3> <div class="item-content"> <ul class=""> <li> <a href="#3"> <span class="item-list-title">Profile</span> <span class="item-list-excerpt">Lorem ipsum dolor sit amet, consectetur adipiscing elit</span> </a> </li> <li> <a href="#3"> <span class="item-list-title">Installation</span> <span class="item-list-excerpt">Lorem ipsum dolor sit amet, consectetur adipiscing elit</span> </a> </li> <li> <a href="#3"> <span class="item-list-title">Settings</span> <span class="item-list-excerpt">Lorem ipsum dolor sit amet, consectetur adipiscing elit</span> </a> </li> </ul> </div> </div> <div class="cfw-menu-item cfw-menu-item-2"> <h3 class="item-title"><a href="#3">Installation</a></h3> <div class="item-content"> <ul class=""> <li> <a href="#3"> <span class="item-list-title">Compatibility</span> <span class="item-list-excerpt">Lorem ipsum dolor sit amet, consectetur adipiscing elit</span> </a> </li> <li> <a href="#3"> <span class="item-list-title">Version</span> <span class="item-list-excerpt">Lorem ipsum dolor sit amet, consectetur adipiscing elit</span> </a> </li> <li> <a href="#3"> <span class="item-list-title">Download</span> <span class="item-list-excerpt">Lorem ipsum dolor sit amet, consectetur adipiscing elit</span> </a> </li> </ul> </div> </div> <div class="cfw-menu-item cfw-menu-item-3"> <h3 class="item-title"><a href="#3">Our Company</a></h3> <div class="item-content"> <ul class=""> <li><a href="#3"><i class="far fa-building"></i>About us</a></li> <li><a href="#3"><i class="fas fa-user-tie"></i>The founder</a></li> <li><a href="#3"><i class="fas fa-users"></i>The team</a></li> <li><a href="#3"><i class="fas fa-map-marked-alt"></i>Location</a></li> <li><a href="#3"><i class="far fa-envelope"></i>Contact</a></li> </ul> </div> </div> <div class="cfw-menu-item cfw-menu-item-4"> <h3 class="item-title"><a href="#3">Features</a></h3> <div class="item-content"> <ul class=""> <li><a href="#3"><i class="far fa-dot-circle"></i>Options</a></li> <li><a href="#3"><i class="far fa-dot-circle"></i>Intergration</a></li> <li><a href="#3"><i class="far fa-dot-circle"></i>Customisation</a></li> <li><a href="#3"><i class="far fa-dot-circle"></i>Styling</a></li> <li><a href="#3"><i class="far fa-dot-circle"></i>Compatibility</a></li> <li><a href="#3"><i class="far fa-dot-circle"></i>Ease of use</a></li> <li><a href="#3"><i class="far fa-dot-circle"></i>Support</a></li> </ul> </div> </div> <div class="cfw-menu-item cfw-menu-item-5"> <h3 class="item-title"><a href="#3">Support</a></h3> <div class="item-content"> <ul class=""> <li><a href="#3"><i class="far fa-dot-circle"></i>Online Chat</a></li> <li><a href="#3"><i class="far fa-dot-circle"></i>Tickets</a></li> <li><a href="#3"><i class="far fa-dot-circle"></i>Telephone</a></li> <li><a href="#3"><i class="far fa-dot-circle"></i>Messenger</a></li> <li><a href="#3"><i class="far fa-dot-circle"></i>Viber</a></li> <li> <a href="#3"> <span class="item-list-title">Address</span> <span class="item-list-excerpt">111 8th Ave, New York, NY 10011, United States</span> </a> </li> </ul> </div> </div> <div class="cfw-menu-item cfw-menu-item-6"> <h3 class="item-title">Social Networks</h3> <div class="item-content"> <ul class=""> <li><a href="#3"><i class="fab fa-facebook"></i>Facebook</a></li> <li><a href="#3"><i class="fab fa-instagram"></i>Instagram</a></li> <li><a href="#3"><i class="fab fa-twitter"></i>Twitter</a></li> <li><a href="#3"><i class="fab fa-youtube-square"></i>Youtube</a></li> <li><a href="#3"><i class="fab fa-pinterest"></i>Pinterest</a></li> <li><a href="#3"><i class="fab fa-dribbble-square"></i>Dribbble</a></li> <li><a href="#3"><i class="fab fa-behance"></i>Behance</a></li> </ul> </div> </div> </div> <div class="cfw-menu-footer"> This is the menu footer </div> </div> <div class="cfw-menu-overlay"></div> </div> </div>

After adding menus and submenus we have a full menu on our site where the user can navigate successfully. It's time now to add some styling to it. Below is the SCSS code have been used for styling:

SCSS Code (precompiled)

_settings.scss

$time_visibility: 0.5s; $menu_rows: 2; $menu_items_num: 6; $menu_subitems_num: 7; $menu_offset_delay: 0.1s; $color_background_body: #227093; // The body background color of the page $color_background_menu_overlay: rgba(17, 18, 17, 0.80); // The menu overlay background color $color_text_main: #ffffff; // The color for text and links inside menu-wrapper. Does not affect anything outside of it. $font_primary: "Cabin", sans-serif; $font_header: "Exo 2", sans-serif;

_menu.scss

/** The main menu div element. Contains all the menu items */ .cfw-menu-wrapper{ overflow-y: auto; @include position(fixed, 0 0 0 0); visibility: hidden; > .inside{ overflow-y: auto; @include position(absolute, 0 0 0 0); } a{ text-decoration: none; &:hover{ text-decoration: none; } } .cfw-menu-content{ padding: 1rem; position: relative; z-index: 999; color: $color_text_main; @include transition(visibility $time_visibility); .cfw-menu-header{ text-align: center; position: relative; color: $color_text_main; font-family: $font_header; padding-left: 1rem; padding-right: 1rem; opacity: 0; visibility: hidden; @include transition(opacity $time_visibility, visibility $time_visibility); > .cfw-menu-title{ padding-bottom: 1rem; margin-bottom: 2rem; border-bottom: 1px solid rgba(255, 255, 255, 0.76); } > .cfw-menu-close{ @include position(fixed, 1rem 0.5rem null null); z-index: 9990; width: 18px; height: auto; cursor: pointer; font-size: 1.5em; } } > .cfw-menu-body{ perspective: 500px; display: flex; flex-wrap: wrap; .cfw-menu-item{ flex: 0 0 100%; max-width: 100%; opacity: 0; visibility: hidden; margin-bottom: 2.5rem; padding-left: 1rem; padding-right: 1rem; @include transition(opacity $time_visibility, transform $time_visibility, visibility $time_visibility); .item-title{ font-size: 1rem; font-weight: 800; margin-bottom: 0rem; padding-bottom: 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.50); > a{ color: $color_text_main; } } .item-content{ > ul{ margin: 0; padding: 0; list-style: none; > li{ perspective: 500px; > a{ display: block; padding: 0.4rem 0; border-bottom: 1px solid rgba(255,255,255,0.15); color: $color_text_main; backface-visibility: hidden; @include transition(transform 0.25s 0.5s); transform-origin: bottom; > i{ margin-right: 0.75rem; width: 20px; color: $color_text_main; opacity: 0.8; } .item-list-title{ display: block; } .item-list-excerpt{ display: block; font-size: 0.925em; color: $color_text_main; opacity: 0.7; } } } } } } } .cfw-menu-footer{ padding-left: 1rem; padding-right: 1rem; text-align: center; font-size: 0.8em; color: $color_text_main; opacity: 0; visibility: hidden; @include transition(opacity $time_visibility $time_visibility/2, visibility $time_visibility $time_visibility/2); } } .cfw-menu-overlay{ @include position(fixed, 0 0 0 0); background-color: $color_background_menu_overlay; opacity: 0; visibility: hidden; @include transition(opacity $time_visibility, visibility $time_visibility); transition-delay: 0.5s; } } /** Styling while menu is visible .cfw-menu-extended class is appended to body tag */ body.cfw-menu-extended{ overflow: hidden; .cfw-menu-wrapper{ .cfw-menu-content{ visibility: visible; .cfw-menu-header{ visibility: visible; opacity: 1; } .cfw-menu-item{ opacity: 1; visibility: visible; transform: translateY(0px) rotateX(0deg); .item-title{ } .item-content{ > ul{ > li{ > a{ transform: rotateX(0deg); @include transition(transform 0.25s 0.5s); } } } } } .cfw-menu-footer{ visibility: visible; opacity: 1; @include transition(opacity $time_visibility $time_visibility*2, visibility $time_visibility $time_visibility*2); } } .cfw-menu-overlay{ transition-delay: 0s; opacity: 1; visibility: visible; } } } @media (min-width: 768px){ .cfw-menu-wrapper .cfw-menu-content{ padding: 2rem; .cfw-menu-header > .cfw-menu-close{ right: 1rem; } > .cfw-menu-body .cfw-menu-item{ flex: 0 0 50%; max-width: 50%; transform: translateY(100px) rotateX(-45deg); .item-content > ul > li > a{ transform: rotateX(120deg); } } } .cfw-menu-wrapper .cfw-menu-content .cfw-menu-item{ @for $i from 1 through $menu_items_num { &.cfw-menu-item-#{$i} { transition-delay: ($menu_offset_delay * $menu_items_num) - ($i * $menu_offset_delay); } } } body.cfw-menu-extended .cfw-menu-wrapper .cfw-menu-content .cfw-menu-item{ @for $i from 1 through $menu_items_num { &.cfw-menu-item-#{$i} { transition-delay: $i * $menu_offset_delay; @for $j from 1 through $menu_subitems_num { > .item-content > ul > li:nth-child(#{$j}) > a { transition-delay: 0.3s + (0.2s * $i) + (0.05s * $j); } } } } } } @media (min-width: 1200px){ .cfw-menu-wrapper .cfw-menu-content{ padding: 3rem; > .cfw-menu-body .cfw-menu-item{ flex: 0 0 #{(100% / $menu_items_num * $menu_rows)}; max-width: #{(100% / $menu_items_num * $menu_rows)}; } } }

JavaScript Code

( function($) { 'use strict'; var extendedClass = 'cfw-menu-extended'; $('#trigger-menu, .cfw-menu-overlay').on('click', function(){ $('body').addClass(extendedClass); }) $('.cfw-menu-close').on('click', function (e) { e.preventDefault(); $('body').removeClass(extendedClass); }) })(jQuery);

As you can see in the code above javascript is responsible for only one thing. To add/remove the class "cfw-menu-extended" from the body tag. It adds the class when the user clicks on the "#trigger-menu" element and removes it when the user clicks the menu close button inside menu wrapper. This class is the reference point where the menu visibility is controled through SCSS and CSS respectively.

Explaining the progressive display of menu items

If you checked the demo page, you should already noticed that menu and submenu elements are progressively visible on the screen. Using the SCSS loop we incrementally change transition-delay on each list item in order to achieve this event. Below is the part of code for this effect. Of course if you need more menus or submenus you must increase the values $menu_items_num and $menu_subitems_num respectively.