Skip to content

Conversation

@jasonyarrington
Copy link

Totally up to you, but if you want you could pull this code in to allow centering of the text vertically in a div. It's useful for responsive labels where the parent elements are fixed height.

myParentHeight = $el.parent().height(),
myPaddingTop = (myParentHeight - myHeight) / 2;

$el.css('padding-top', myPaddingTop + 'px');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use margin-top. Padding top values will not collapse for elements that are vertically stacked.

http://stackoverflow.com/questions/2189452/when-to-use-margin-vs-padding-in-css

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant