Skip to content

Instantly share code, notes, and snippets.

@aarongarciah
Last active August 29, 2015 14:22
Show Gist options
  • Save aarongarciah/3778d31ac45dd31585d5 to your computer and use it in GitHub Desktop.
Save aarongarciah/3778d31ac45dd31585d5 to your computer and use it in GitHub Desktop.
Vertical align an inline-block element using parents pseudo element :before or :after. Doesn't matter the height of the parent or the height of the element.
#parent { font-size: 0px; }
#parent:before { content: ''; display: inline-block; height: 100%; vertical-align: middle; }
#element { display: inline-block; vertical-align: middle; font-size: 10px; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment