Skip to content

Instantly share code, notes, and snippets.

@tsi
Created August 22, 2013 06:55
Small and useful mixin to easily set width and height to your elements. It can be used with any kind of unit or even with an image name so it gets the dimensions from the image. See https://coderwall.com/p/2k3rgw for the full post.
@mixin size($x, $y: $x) {
@if type_of($x) == string {
width: image-width($x);
} @else {
width: $x;
}
@if type_of($y) == string {
height: image-height($y);
} @else {
height: $y;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment