The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Vertical align image sprites horizontally in footer Re: Vertical align image sprites horizontally in footer


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.

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” :)