Vertical align image sprites horizontally in footer

I created a class with a ul that aligned images vertically across the footer. Now I’m going with sprites and I’m aware they’re individual, that’s okay with me. One of the sprites is smaller height. How do I get them to align vertically without using the margin-top on the one li on the ‘Western Growers’ logo. Since I prefer to learn the most proper technique, I’d like to use a ul class=”social” instead of wrapping it in a div like it is now.

There are some catches that will cause initial issues when switching over to `display: inline-block;` so I’ll go through all the changes.

At the moment the `.social` is hard coded to 606px width. Instead of defining such a width you want to use `text-align: center;` which gives you the effect of everything centered (once everything is `inline-block`). Major advantage here is that you can add or remove any item in the footer and it’ll still appear centered. Dynamic stuff.

Next: `.social ul` is floated. We actually don’t want (or need) that now so remove clear, float, height, width. No need to define things that don’t have any effect :)

`.social li` also has more than needed. We make it a regular `inline` element. It can be `inline-block` too if wanted, but that doesn’t really give us anything right now and `inline` is shorter to type (best reason ever). So remove: float, height, line-height. Replace `margin-right: 80px;` with `margin: 0 30px;` (total space between images will be roughly 65px this way as there is extra space character in the middle, so you get 30px + space character + 30px). Then also set `display: inline;`

Remove `style=”margin-top:26px;”` in the HTML.

`.social li a` currently has `line-height: 104px;` – you can keep this rule here or move it up and give it to `.social` as it’ll be inherited to all child elements. Add `display: inline-block;` and `vertical-align: middle;` and we’re almost done with the changes.

Finally you have `.social li:last-child` to remove `margin-right` – this style has just become unnecessary as we’ve replaced it with margin that is equally on the both sides of each list element.

**Edit!**
Some additional stuff: you can also remove fixed height from `#footer` and use `line-height` in `.social` to control the height of the element, while still vertically centering the list elements to the middle. The elements are no longer floated so you don’t have issues with elements going “out of the flow” :)

Tips

What now? I have some ideas for you.

Go explore CodePen!

As a front end designer and developer, you should have an account on CodePen so you can save your snippets, present your ideas, and engage with other front end folk. I'd encourage you to go PRO as well, to unlock the full power of CodePen.

Get the newsletter!

You should sign up for the CSS-Tricks newsletter. It's a clean copy of all the blog posts each week, combined together, right to your inbox. If email isn't your thing, there is an RSS feed, iTunes, and lots of other ways to subscribe.

Listen to ShopTalk!

Subscribe to The Lodge!

The Lodge is a members-only, ad-free video learning area here on CSS-Tricks. Just like the free screencasts, but organized into four large complete series. Membership is also the #1 best way to support CSS-Tricks.

We can do the real footer now.

Site Links

Colophon

CSS-Tricks* is created, written by, and maintained by Chris Coyier. It is built on WordPress, hosted by Media Temple, and the assets are served by MaxCDN. The fonts are Source Sans and Source Code Pro. It is made possible by viewers like you who subscribe to The Lodge and through advertising for products and services I like.