Adding icons

It's time to add icons to our navigation. We'll begin by employing the Glyphicons that come with Bootstrap. Then, we'll shift to the larger library of icons offered by Font Awesome.

Note

Take a moment to review the relevant Bootstrap documentation at: http://getbootstrap.com/components/#glyphicons.

You'll see the set of icons available and the markup convention for using these in your HTML using span tags and glyphicon classes. We'll start by adding a home icon to our Home nav item:

  1. Add the Glyphicon Home icon to the Home nav item by placing a span tag with appropriate classes within the nav item link and before the text:
    <li class="active">
      <a href="EB9781782164524_3.html">
        <span class="glyphicon glyphicon-home"></span> Home
      </a>
    </li>

    Tip

    I've added a space after the span tag to provide a bit of space between the icon and the text Home.

  2. Save this and refresh your browser. If all goes well, you should see your icon appear!
    Adding icons
  3. If your icon does not appear, check the following things:
    • Are the Glyphicon fonts in the fonts folder?
    • Is the @icon-font-path variable set properly in your _variables.less file? The @icon-font-path:"../fonts/"; path is working for me.
  4. Assuming that all is working, let's press on and add icons to each of the other nav items. Here are the remaining span elements and classes I'll use, in this order, for Portfolio, Team, and Contact.
    <span class="glyphicon glyphicon-picture"></span>
    <span class="glyphicon glyphicon-user"></span>
    <span class="glyphicon glyphicon-envelope"></span>
  5. Save and refresh. You should get the following result for all computer screen sizes:
    Adding icons
  6. And, in the collapsed responsive navigation:
    Adding icons

Not too bad.

Of course, our icons don't exactly match the icons from the mock-up. Here is what the mock-up called for:

Adding icons

The free version of Glyphicons provided with Bootstrap does not include icons for a computer monitor or a group of people. As we look through the available Glyphicons, we'll also find there are no icons for our social media links in the footer.

Fortunately, we have other icon options available. Let's consider one of them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset