Skip to content

Instantly share code, notes, and snippets.

@tsi
Created August 22, 2013 06:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsi/6304012 to your computer and use it in GitHub Desktop.
Save tsi/6304012 to your computer and use it in GitHub Desktop.
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