At this point we’re just about done with the homepage of our responsive website. We’ve got our navigation in place, our background images resize nicely, and our other elements are able to resize and adjust to various screen resolutions.
Today we’re going to focus on tying the page off with a footer. I’ve always admired sites that put some thought in to the bottom of their page design. There are certainly times when a footer requires nothing more than some basic contact info and maybe a copyright claim.
But I think it’s a good idea with any site requiring a fair amount of vertical scrolling to go ahead and add a smaller version of your main navigation in to your footer. This allows the viewer to reach the end of your page and quickly jump to another page on the site. We’ll put the icing on our footer by feeding in our latest tweet with a little jQuery script and then sprinkle in some contact info. Before we dive in to it, let’s take a quick peek at what we’re working towards.
Much like a website’s header, I like to use a separate file for my footer and dynamically pull it in to each page with a php include.
This makes for quick and easy updating if a link is added or contact info changes. Go ahead and open your idex.php file and include your footer, mine is sitting just above the close of my body tag and looks like this.[crayon-54f01c30ecd9e464527112/]
That’s it for our index.php page, go ahead and save it then close out of that file. Next up we’re going to want to create our footer file and enter all of our content, so open a new document and save it as “footer.php”. The first tag we’re going to want to drop in our footer.php file is our container id.
This will keep our footer content centered on the page and aligned nicely with the rest of our main content above. You’ll notice in the image of our footer above that it’s broken down in to three sections, so we’re going to want to include a “footerLeft” class right after we open the container.
We then populate our “footerLeft” class with a miniature version of our main navigation, and then icons linking to our social media pages. At this point my code looks like this.[crayon-54f01c30ecdca950708279/]
Our middle section is our Twitter feed and is only three simple lines of code, an image wrapped in a div class I named “twitter”. Our content is populated by jQuery and is set to recognize our “twitter” class as the appropriate location to place our latest tweet. We’ll dive in to this in our next tutorial.[crayon-54f01c30ecde2251696607/]
Lastly we have some contact info, which I aptly named “contact”. From there simple paragraph and line break formatting displays our contact info.[crayon-54f01c30ecdf5146984239/]
That does it for our footer.php file. Feel free to check your work against my full footer.php code or save your work and close out of this page.[crayon-54f01c30ece07289522708/]
Now that all of the content is entered in to the appropriate files, we can begin to style it. Our regular HTML5 footer tag sets the height, color, and font style for our footer. I also put a thick top border to help separate our footer from our portfolio slider above.[crayon-54f01c30ece1d238773889/]
The .footerLeft class gets a little tricky as there’s quite a bit going on in there with our mini main navigation list elements and images. Most of this is basic styling, but there are a couple things worth pointing out.
Since we don’t have too much room to make our mini navigation bar fluid and keep it on the same line with decent spacing, I made its width specific. We’ll rely on the Twitter and contact sections for our minor width adjustments.
Also, it’s worth pointing out that the inline display under our list element is important to maintain the same horizontal appearance of our page links.[crayon-54f01c30ece31766062811/]
Next up we have our Twitter section, notice how we’re back to a percentage based width. We’re also able to style the time stamp of our tweets to subtly pronounce the time of our last tweet.[crayon-54f01c30ece45668389462/]
Lastly, we’ll add some spacing to our contact section for an evenly spaced look.[crayon-54f01c30ece58367273958/]
Next week we’ll finish off the styling to make our footer fully responsive as well as discuss the jQuery Twitter feed. In the mean time, test your responsive skills and see if you’re able to make your footer responsive. Click here to download the source code.