Contents  >

Travel Agency Project:
Menus

Introduction

In this task you will use template content to add desktop and mobile menus to the ‘Travel Agency’ project you created earlier and to which you then added a contact form page and a footer.

You can display a finished version of the project web pages by clicking the image below.

Web Design Project: Travel Agency 2n2l.com Brendan Munnelly

Learning Goals

At the end of this Tutorial you will be able to:

Contents

Introduction

Downloading the website logo image

Working with your two HTML files

Copying-and-pasting the menus HTML and JavaScript

Working with the template CSS file

Copying and renaming the template CSS file

Removing browser resets from the new menus CSS file

Updating the font-family for the menus

Linking your web page to the new menus CSS file

Updating the menu logo and hyperlink

Updating the menu option hyperlinks

Creating the hyperlink destinations

Offsetting the hyperlink destinations

Updating the hero block spacing

Updating the mobile menu content and hyperlinks

Updating the menu colours

Adding the menu style-swapping effect

Changing the colour of the hamburger icon

Updating the other three web pages

Uploading your project to GitHub

Working with your two HTML files

You will begin by working with two HTML files:

  1. In Visual Studio Code, from your websites/templates folder, open the following HTML file;   menus-template.html fa-icons-copy
  2. From your websites/portfolio/travel folder, open the web page named index.html. fa-icons-copy

If you have any other files open in Visual Studio Code, you may wish to close them.

fa-icons-copy

This will help you to focus only on the two HTML files you will be working with.

Copying-and-pasting the menus HTML and JavaScript

Your next step is to copy content from the menus template file into your index.html web page.

  1. In the menus-template.html file, select and copy the menus-related HTML blocks. fa-icons-copy
  2. In your index.html web page, click just after the start of the opening <body> tag, and press the ENTER key a few times to open up some new lines of blank space.
  3. Paste the copied HTML for the menus.
  4. Switch back to the menus-template.html file, and select and copy the JavaScript code for the menus. fa-icons-copy
  5. In your index.html web page, scroll down to near the end of the web page, to just before the closing </body> tag.
  6. Press the ENTER key a few times to open up some new lines of blank space.
  7. Paste the copied JavaScript code for the menus.
  8. When finished, save your index.html web page.

You can close the menus-template.html file. You are now finished working with this template.

Updating the hero block spacing

Because both the desktop/laptop and mobile parent containers are ‘sticky’, the menus remain fixed at the top of the screen as the user scrolls down through the web page.

fa-icons-copy

This also means that the top 72px of whatever web page element immediately follows the parent menu containers is ‘hidden’ behind them.

So you need to make a few changes to the hero block: to its height and to the vertical positioning of its text content.

  1. In VS Code, display the style.css file.
  2. Edit the height of the container-hero class for desktop/laptop and mobile screens as shown below.   Also, add some margin spacing above the main <h1> heading. fa-icons-copy
  3. Save your style.css file.

View the effect on your web page on desktop/laptop and mobile size screens.

Updating the mobile menu content and hyperlinks

In the lower part of the mobile menu, under the <hr> horizontal rule line, you can include some text about yourself, an image and some hyperlinks.

  1. If you wish to include a profile picture, the link to the placeholder image is as follows.
    <img src="assets/img/profile-pic.jpg" alt="Mary Smith, Web Designer"> 
    
  2. If you wish to include an email address or social media hyperlinks, replace the template-provided details with your own. Delete any details in the template you do not want to include.
  3. If you want to link your website’s Home page, the link should be as follows.
    <a href="../../index.html">Home</a>
    
  4. If you want to link your website’s Portfolio page, the link should be as follows.
    <a href="../index.html">Portfolio</a>
    
  5. And if you want to link your website’s Contact Form page, the link should be as follows.
    <a href="../../contact/index.html">Contact</a>
    
  6. Save your index.html web page.

Updating the menu colours

In the menus-template.html file you copied-and-pasted into your index.html web page, the CSS class of menu-light is assigned to the desktop and mobile menus. As a result:

Let’s replace this default colour of red with the orange colour of #ff5000 used elsewhere in the web page.

  1. In VS Code, display the menus.css stylesheet.
  2. On the Visual Studio Code menu, click the Edit menu and then click the Replace command.
  3. A new search-and-replace dialog box appears at the top-right of the Visual Studio Code screen. fa-icons-copy
  4. In the first field, enter red.
  5. In the second, enter #ff5000.
  6. Click the left icon for Replace. Do not click the right icon for Replace All.
  7. One by one, replace every occurrence of the colour red with #ff5000 in your stylesheet.   (If you choose the Replace All option, Visual Studio Code will replace the letters ‘red’ inside words such as 'centered' that may be written in comments.)
  8. Save the menus.css file.

In your web browser, the web page should look as shown below.

fa-icons-copy

Adding the menu style-swapping effect

Your final step is to use some JavaScript code in the menus-template.html file you copied-and-pasted into your index.html web page to create the following effect:

To achieve this effect, follow these steps.

  1. In the index.html file, for both the container-menu-desktop and container-menu-bar-mobile containers, replace the class of menu-light with the menu-transparent class as shown below. fa-icons-copy
  2. Save the index.html file, and view the result in your web browser at both desktop/laptop and mobile screen sizes. fa-icons-copy Unfortunately, on desktop/laptop screens, the white coloured menu options are impossible to read against the light coloured page background.
  3. Display the index.html web page in VS Code.
  4. Scroll down to near the bottom of the web page, and remove the // characters from the beginning of the JavaScript code as shown below. fa-icons-copy
  5. Save the index.html file.

In your web browser, the web page should look as shown below as you scroll down and back up the screen.

. fa-icons-copy

When the user scrolls down the web page:

When the user scrolls back up the web page:

Changing the colour of the hamburger icon

The hamburger icon, which is displayed only on mobile screens, is shown in the same orange colour as the menu options text whenever the menu has a transparent background.

To make the hamburger icon more visible against the background image, let’s change its colour from orange to white.

  1. In VS Code, open the menus.css stylesheet.
  2. Change the icon colour, which is created by the background-color property, to white (#fff). fa-icons-copy
  3. Save the menus.css file. You can now close this stylesheet.

Updating the other three web pages

You need to apply the menu-related updates you have made to your index.html web page to the three other web pages in your 'Travel' project. Follow these steps.

  1. In VS Code, display your index.html web page, and from the <head>, copy the link to the menus.css stylesheet. fa-icons-copy
  2. Open your destinations.html, about-us.html and contact-us.html web pages.
  3. Paste the CSS link into the <head> of those three web pages.
  4. Return to your index.html file and copy all the menu-related content from the top of the web page. fa-icons-copy
  5. Into the top of your destinations.html, about-us.html and contact-us.html pages, paste the menu-related content to just after the opening <body> tag.
  6. Return to your index.html file and, from the bottom of the web page, copy all the JavaScript code for menus. fa-icons-copy
  7. At the end of the destinations.html, about-us.html and contact-us.html web pages, to just before the closing </body> tag, paste the copied JavaScript code.
  8. Save your destinations.html, about-us.html and contact-us.html web pages.

In your web browser, display the web pages and verify that the menu hyperlinks between the four pages all work correctly, both on desktop/laptop and mobile size screens.

That’s it. You have now completed your ‘Travel’ project.

Uploading your project to GitHub

The final step is to upload your project to GitHub.

All the files you have updated for this project are in the travel sub-folder of your websites/portfolio folder.

So the easiest option is simply to upload the entire travel sub-folder to your account on GitHub.

  1. If you are not already signed in to your GitHub account, sign in now.
  2. On the left of your GitHub home page, click the name of the repository that holds your web pages.
  3. On the next GitHub screen displayed, click the portfolio folder. GitHub Upload
  4. GitHub should now display your portfolio folder. github-upload-portfolio
  5. With the portfolio folder displayed on your GitHub screen, click the Add file button and, from the dropdown list displayed, choose the option Upload files. Project Animation Google Fonts
  6. In File/Windows Explorer on your computer, display your portfolio folder and then drag-and-drop the travel folder to the GitHub tab in your web browser. github-upload-drag-drop
  7. After uploading the travel folder, scroll down to the bottom of the GitHub screen, enter a short message in the Commit changes box, click the Commit changes button, and wait for the upload to complete. github-upload-progress

Your updated ‘Travel Agency’ web project is now published on GitHub at a web address similar to the following, where username is the username you have chosen for your GitHub account:

https://username.github.io/portfolio/travel/index.html

or, simply:

https://username.github.io/portfolio/travel

It may take a few minutes for your uploaded files to appear on GitHub.



Return to Contents.