Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJoseph Greco
13,405 PointsSass Calculation Formula Mixin
I'm want to create a mixin in Sass to vertically align an element within a div. My idea is to calculate the difference between the divs height and the nested elements height, then divide it by two which would be used as top and bottom padding.
@mixin vertical_align($outterHeight, $innerHeight){
padding-top: calc($outterHeight - $innerHeight / 2);
padding-bottom: calc($outterHeight - $innerHeight / 2);
}
input{
height: 40px;
}
i{
height: 28px;
}
i{
@include vertical_align(40px,28px);
}
I don't have have much experience using mixins and this doesnt work. Can anyone point me in the right direction?