Horizontal Navigation with Flexbox

In this session, we'll look at how we can apply Flexbox to a list of links to create a horizontal nav.

Housekeeping


1. Activity: Dissect a nav menu

Instructions

Search for an example of a horizontal navigation menu online that you think you can duplicate.

  1. Using the eyedropper tool, create a color palette based on your selected menu.
    • Don’t forget hover and active states.
  2. Using the Font panel of the Inspector, try to find the font(s) used in the navigation.
  3. Turn on the phone emulator in the inspector and open the mobile menu on your selected site. Take a screen cap of this menu for reference in the next activity.

2. Accessible Horizontal Navigation

Flex navigation slides

Materials


3. Activity: Make your own vertical nav menu

Try to duplicate the nav menu and banner using today’s slides and sample code.

  1. Create a list of HTML links using the <nav> and <ul> elements.
  2. Using CSS, remove the default bullets and padding from the <ul>.
  3. Make your links clickable by adding padding (and by making your links block-level).
  4. Define your colours according to your selected palette from the earlier activity
  5. Define your fonts and any other styles needed to match your nav bar to your online example.

4. Demo: Flexbox Basics

Materials


5. Activity: Horizontal navigation with Flexbox

Try to duplicate the nav menu and banner using today’s slides and sample code.

  1. Set your <ul> to display: flex.
  2. Choose a justification setting based on your example navigation.
  3. Stretch: Create a list of <img> elements from Lorem Picsum and create a gallery with Flexbox.
    • What element will be your flex container?
    • Try using gap to space out your images

Today's Achievement

Note: for the rest of this course, the Proof of Work portion of the Daily Achievements will be 100% of the marks awarded. The Learning and Reflection portion are no longer for marks.

Complete FlexBox Froggy

Try to complete all 24 levels of the Flexbox Froggy learning game. Take a screencap of the expanded Level Menu to show how many exercises you completed.

Screencap of a completed Flexbox Froggy game

You will receive partial marks for each level you complete (around 1/3 marks for each 8 levels completed).


Prep

Reading list

Watch list

Digging deeper (optional)

  • What the Flexbox!?!
    • A 20-video course on Flexbox by Web Bos;
    • Watch these videos if you want to learn more about Flexbox than what we cover in class.