Created
October 30, 2013 15:20
-
-
Save mcranston18/7234442 to your computer and use it in GitHub Desktop.
Directive to vertically align in CSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive('verticalAlign', function () { | |
return { | |
restrict: 'A', | |
link: function (scope, elm, attrs) { | |
var childHeight = elm[0].clientHeight; | |
var parentHeight = elm[0].parentElement.clientHeight; | |
var offset = (parentHeight - childHeight) / 2; | |
elm[0].style.paddingTop = offset + 'px'; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment