The following files are required for this lesson:

Introduction

This lesson will be taught in two parts:

Demo Instructions

You can follow along with your instructor to complete this build and/or you can use this document as a guide in completing the demo build.

Steps - Part 1: Single-level Navigation

  1. Download the demo-single-level-nav-main.zip file and extract its contents to a folder named demo-single-level-nav-main.
  2. The completed output should look like:
    single-nav-01.jpg
    Note: When the browser is resized, the menu will start to wrap to the next row.
  3. The index.html file needs to be updated as follows:
    1. Modify the <head> to be:
      single-index-01
    2. Add the following to the <body>:
      single-index-02
  4. The web page should now look like:
    single-nav-02.jpg
    Question: What needs to be done to the menu?
  5. Open the styles.css and add the following style rules:
    1. Style the <body> element:
      single-css-styles-01
    2. Style the <header>:
      single-css-styles-02
    3. Style the menu <ul>:
      single-css-styles-03
    4. Style the <a> elements of the menu:
      single-css-styles-04
      Your web page should now look like:
      single-nav-03
      Question: what needs to be done next?
    5. Now add the media query:
      single-css-styles-05
      Question: What does this media query do? What size is 30em?
    6. When you resize your browser, you should see something like:
      single-nav-04
  6. The img folder contains several SVG files. As a challenge, add these to your menu items and modify your styles.css code to produce the following output:
    single-nav-05.jpg
    Note: the green text is a hover effect.

Steps - Part 2: Multi-level Navigation

  1. Download the demo-multi-level-nav-main.zip file and extract its contents to a folder named demo-multi-level-nav-main.
  2. The completed output should look like: multi-01.jpg
    Note: The Events menu also ahs a dropdown menu.
  3. Add the following code to index.html:
    1. Update the <head> to be:
      multi-index-01
    2. Add the <header>:
      multi-index-02
    3. Add the sub-menu for Books:
      multi-index-03
    4. Add the sub-menu for Events:
      multi-index-04
    5. Add the SVG symbol to indicate there is a sub-menu (it is the same SVG for both Books and Events) after the menu item name and before the <a> tag:
      multi-index-05
      The code is easier to just copy and paste the <path d="…"> from the SVG file in the img folder into your code editor.
  4. Running index.html in your browser should now look like:
    multi-02.jpg
    Question: What needs to be done now?.
  5. Open your styles.css file and add the following style rules:
    1. Style the <body> and <header> elements:
      multi-css-styles-01
    2. Add a style rule for the <ul> in the menu:
      multi-css-styles-02
    3. Style the <a> elements in the menu:
      multi-css-styles-03
    4. Add a hover effect to the menu links:
      multi-css-styles-04
    5. Style the sub-menus and the SVG:
      multi-css-styles-05
  6. Refreshing your browser, you should now see something like:
    multi-03.jpg
    Question: What is next?.
  7. It is time to add a media query to styles.css:
    1. Add a media query and style the menu:
      multi-css-styles-06
    2. Add another rule to your media query to style the list items:
      multi-css-styles-07
    3. Add rules to style the sub-menu:
      multi-css-styles-08
    4. Add rules to style the dropdown for the sub-menus:
      multi-css-styles-09
    5. There does not appear to be a significant change if you now refresh your browser. You need to hide and position the sub-menus by adding the following rule:
      multi-css-styles-10
    6. Now add some layout rules for the menus:
      multi-css-styles-11
      The sub-menus are hidden but still affect the display of the menu:
      multi-04
      Notice the vertical scroll bar which indicates there is still something there.
      Question: How can this be fixed?
    7. Add a rule for the hover state of the sub-menus:
      multi-css-styles-12
    8. Add a transition effect for the menu:
      multi-css-styles-13
    9. Add accessibility and tab navigation:
      multi-css-styles-14
      Refresh your browser and use the tab key to tab through the menus.
      multi-05
    10. Add another media query:
      multi-css-styles-15
      multi-06
      Question: What happened?

Question: In step 7.g, the vertical scrollbar was seen but after all the style rules were applied it was still there, why?

Module Home

DMIT1530 Home