Table of Contents for
Mastering Responsive Web Design

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition Mastering Responsive Web Design by Ricardo Zea Published by Packt Publishing, 2015
  1. Cover
  2. Table of Contents
  3. Mastering Responsive Web Design
  4. Mastering Responsive Web Design
  5. Credits
  6. About the Author
  7. Acknowledgment
  8. About the Reviewers
  9. www.PacktPub.com
  10. Preface
  11. What you need for this book
  12. Who this book is for
  13. Conventions
  14. Reader feedback
  15. Customer support
  16. 1. Harness the Power of Sass for Responsive Web Design
  17. The basic concepts of Sass for RWD
  18. Summary
  19. 2. Marking Our Content with HTML5
  20. The
  21. The
    element
  22. The
  23. The
    element
  24. The
  25. The
  26. Using WAI-ARIA landmark roles to increase accessibility
  27. A full HTML5 example page with ARIA roles and meta tags
  28. Output screenshots for desktop and mobile
  29. Summary
  30. 3. Mobile-first or Desktop-first?
  31. Sass mixins for the mobile-first and desktop-first media queries
  32. Dealing with legacy browsers
  33. How to deal with high-density screens
  34. Sometimes RWD is not necessarily the right solution
  35. Retrofitting an old website with RWD
  36. Retrofitting with AWD
  37. Retrofitting with RWD
  38. Summary
  39. 4. CSS Grids, CSS Frameworks, UI Kits, and Flexbox for RWD
  40. CSS grids
  41. CSS frameworks
  42. UI kits
  43. The pros and cons of CSS frameworks for RWD
  44. Creating a custom CSS grid
  45. Building a sample page with the custom CSS grid
  46. Stop using CSS grids, use Flexbox!
  47. Summary
  48. 5. Designing Small UIs Driven by Large Finger
  49. The posture patterns and the touch zones
  50. The nav icon – basic guidelines to consider for RWD
  51. The navigation patterns for RWD
  52. Summary
  53. 6. Working with Images and Videos in Responsive Web Design
  54. Third-party image resizing services
  55. The element and the srcset and sizes attributes
  56. Replacing 1x images with 2x images on the fly with Retina.js
  57. Making videos responsive
  58. The Vector Formats
  59. Summary
  60. 7. Meaningful Typography for Responsive Web Design
  61. Calculating relative font sizes
  62. Creating a Modular Scale for a harmonious typography
  63. Using the Modular Scale for typography
  64. Web fonts and how they affect RWD
  65. Sass mixin for implementing web fonts
  66. Using FlowType.js for increased legibility
  67. Summary
  68. 8. Responsive E-mails
  69. Don't overlook your analytics
  70. Recommendations for building better responsive e-mails
  71. Responsive e-mail build
  72. Third-party services
  73. Summary
  74. Index

The nav icon – basic guidelines to consider for RWD

The nav icon can be represented in many ways. RWD takes patterns from mobile apps since small screens apps and websites have many similar metaphors.

Let's take a look at the common navigation icon patterns:

  • The hamburger icon.
  • The word Menu.
  • The hamburger icon plus the word Menu.

The hamburger icon

This is by far the most popular icon used to represent the navigation button: ≡.

The hamburger icon was created by Norm Cox in 1981. Norm's intention with this icon was to "…mimic the look of the resulting displayed menu list." (http://gizmodo.com/who-designed-the-iconic-hamburger-icon-1555438787).

In other words, the hamburger icon's real name is the list icon.

Now, if we think about it, the hamburger icon is semantically correct because it represents exactly what is displayed when it's triggered: a list of items. However, some UX studies have revealed that the hamburger icon isn't as effective as we may think, and yet we see it all over the place in both responsive sites and mobile apps.

Although the hamburger icon has several cons, it's a matter of time before practically everyone is able to recognize this icon as a representation of navigation.

The bottom line is that there's nothing wrong with using the hamburger icon as long as we follow the target size recommendations and make the links inside the navigation bar easy to tap on small screens.

The advantages are as follows:

  • It's easily recognized by certain demographics, especially young ones.
  • It takes up very little space in a design.
  • It's not language dependent.
  • It's easy to make using the Unicode character 2261 (≡), which has a global support of 96 percent.

The disadvantages are as follows:

  • It's not easily recognized by some demographics, especially older ones.
  • Although very popular, a lot of people have a hard time understanding that the hamburger icon represents a menu.
  • It promotes low discoverability since a site's navigation will usually be hidden.

If you plan to use the hamburger icon, don't bother using images of any kind or any CSS techniques with borders or box shadows. Keep it simple. All you need to do is use the Unicode character 2261 (≡).

In the following examples, we are going to use a well-known technique to hide content (with a few variations to fit our demos): the Kellum Method. This method is not in any way a hack or anything similar; we are not trying to deceive our users or the search engines with this approach. We're actually being quite mindful of the improved accessibility the navigation icons gain by leaving the text in the markup so that users with assistive technologies can still access the menus. Consider the following example.

The HTML is as follows:

<button class="hamburger-icon"><span>Menu</span></button>SCSS
//Hamburger Icon
.hamburger-icon  {
    //Basic styling, modify if you want
    font-size: 40px;
    color: #666;
    background: #efefef;
    padding: 0 10px;
    border-radius: 3px;
    cursor: pointer;
    //Hamburger Icon
    &:before {
        content: '≡';
    }
    //Hide the term Menu from displaying without sacrificing accessibility
    span {
        display: inline-block;
        width: 0;
        height: 0;
        text-indent: -100%;
        overflow: hidden;
        white-space: nowrap;

    }
}

The result is this one:

The hamburger icon

Tip

The word Menu should always be included in the markup for accessibility reasons. When users with assistive technology (AT) will focus on the hamburger icon, the screen reader will read the word Menu. Also, enclosing the word Menu in <span> tags allows us to hide the word from being displayed in the browser without hurting the accessibility of the link.

The word Menu

Some informal tests on the web have yielded that using the word Menu is the most trusted solution to the drawbacks of the hamburger icon.

However, it's important to note that the studies and tests done by many authors where they compare the hamburger icon versus the word Menu can be misleading, since they are testing different visual languages: an icon versus a word.

For these tests to be fully reliable, they would have to test icon versus icon, and word versus word. For example, testing the hamburger icon against an arrow pointing down or the word Menu against the word Nav.

Let's look at the pros and cons of the word Menu.

The advantages are as follows:

  • It's self-explanatory.
  • Virtually anyone from any demographic can understand what it means.
  • It can be used in any language.
  • It takes up very little space in the design.

The disadvantage is as follows:

  • It may clash with an iconography system since it's a word.

Consider the following example.

Here's the HTML:

<button class="word-menu">Menu</button>

And here's the CSS:

//Word "Menu"
.word-menu {
    //Basic styling, modify if you want
    display: inline-block;
    padding: 16px 8px;
    color: #666;
    font: 12px Arial, "Helvetica Neue", Helvetica, sans-serif;
    background: #efefef;
    border-radius: 3px;
    cursor: pointer;
}

And this is the result:

The word Menu

Tip

In this example, I used the class name .word-menu to explicitly represent my intent for this book, but this is not the proper way to name your elements for production. Use more meaningful and universal naming conventions, for example, something like .menu-trigger could be an alternative. Using a generic class name will allow us to use any design for the navigation icon without altering the markup.

The hamburger icon plus the word Menu

One alternative to the hamburger icon versus the word Menu discussion is to use both at the same time. Some argue that we may get the best of both worlds by doing this.

The advantages are:

  • It's self-explanatory.
  • Virtually anyone from any demographic can understand what it means.
  • It can be used in any language.
  • It can still take up very little space in the design.
  • It is easy to make using the Unicode character 2261 (≡), which has a global support of 96 percent.

The disadvantage is:

  • Depending on the design, the word Menu could be too small.

Let's look at two styles that we can use to represent this pattern.

Consider the following example.

The HTML is as follows:

<button class="hamburger-icon-plus-menu style-1">Menu</button>

The SCSS is as follows:

//Hamburger Icon Plus Word "Menu" – Style 1
.hamburger-icon-plus-menu {
    //Basic styling, modify if you want
    display: inline-block;
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    background: #efefef;
    color: #666;
    border-radius: 3px;
    cursor: pointer;
}
.style-1 {
    padding: 16px 8px;
    font-size: 16px;
    //Hamburger Icon
    &:before {
        content: '≡ ';
    }
}

The result is as follows:

The hamburger icon plus the word Menu

Tip

Notice the space after the ' ', that's what separates the icon from the word "Menu" without having to use margins of any kind.

Consider the following example.

The HTML is:

<button class="hamburger-icon-plus-menu style-2">Menu</button>

The SCSS is:

//Hamburger Icon plus Word "Menu" – Style 2
.hamburger-icon-plus-menu {
    //Basic styling, modify if you want
    display: inline-block;

    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    background: #efefef;
    color: #666;
    border-radius: 3px;cursor: pointer;
}
.style-2 {
    padding: 4px 12px 6px;
    font-size: 10px;
    line-height: .8;
    text-align: center;
    //Hamburger Icon
    &:before {
        display: block;
        content: '≡';
        font-size: 40px;
    }
}

And here's the result:

The hamburger icon plus the word Menu

You can see a demo I created in CodePen at http://codepen.io/ricardozea/pen/f4ddc6443bc060004b58a7301aae83db.