Responsive Layout with Bootstrap

Purpose: The class project requires you to make your pages responsive to different widths, so users on wide devices and users on phones can both use your site. The main requirement is that there is no horizontal scrolling or cut-off content. It also requires you to make your non-text elements accessible for those with screen-readers using "aria-label" and similar attributes. This exercise focuses on doing this to the nav bar, since the nav is one of a difficult element to make responsive and accessible. This exercise uses the Bootstrap library.

Required Reading

Please review the following materials about responsive design using Bootstrap and CSS3:
Bootstrap Nav Components
Using @media Queries for Accessibility
Accessiblity Labels (label, aria-label, and legend)

Make a Minimal Collapsible Toggle Button

Please re-type the following code into a new file (name it something like test.html) and pay attention to the notes below:

Please review the following notes on the code above. Please change each feature described below at least once to prove to yourself what they do:

Some of these effects are not hard to achieve using vanilla javascript and CSS, and some of them require several lines of code. Bootstrap is useful because it puts all these effects together in one place.

Add aria-label to the Hamburger Menu for Accessibility

The "aria-label" attribute lets a screen reader know what to say when a non-text element is touched (like the hamburger menu for example). When the element is collapsible, the following aria attributes are needed to direct the screen reader:


aria-controls="elementid"
aria-expanded="false"
aria-label="Toggle navigation"

Please add these attributes to the <button> element.

Make Nav and Footer Responsive, Accessible, and Professional-Looking

Start with the code you made in exercise 1.3 and re-type the following code to replace nav.html and footer.html.


nav.html

footer.html

In index.html, about.html, and contact.html, include bootstrap CSS at the top, as follows:
and bootstrap JS at the bottom, as follows:
Also, add the following CSS to complete the professional look (either in a <style> tag or in a separate CSS file):

Please review the following notes on features that weren't in the previous example. Please change each added feature described below at least once to prove to yourself what they do:

The whole page should work like the following:

Note on best practices

Some browsers will not behave right unless you include <meta> tags that specify things like character set and viewport scale. Particularly, phone browsers tend to pretend they are wider than they are unless you use this meta tag. It is considered best practices to include the following types of tags and to wrap all <meta> and <link> tags inside the <head> tag (as well as js includes, unless the js needs the DOM to be rendered first), as follows:

You can use AJAX includes to include this type of head information, but beware: it is not wise to try to include <script> tags in an AJAX-included file. Since we are using the innerHTML attribute to import the included code, most browsers will not run the included script tags. If you do include such tags, you will end up needing to write more functions to run the script tags.