Skip to content

Instantly share code, notes, and snippets.

@krisbulman
Created April 22, 2014 14:21
Show Gist options
  • Select an option

  • Save krisbulman/11181086 to your computer and use it in GitHub Desktop.

Select an option

Save krisbulman/11181086 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div class="example">Calc Test</div>
// ----
// Sass (v3.2.19)
// Compass (v0.12.6)
// ----
// Calc
// Provides fallback and vendor-specific prefixes for calc.
// http://caniuse.com/calc
//
// $property - Ex: 'max-width'.
// $expression - Expression to calculate the value from. Ex: '100% - 60px'.
// $fallback - Expression for browsers without calc support. Ex: '80%'.
@mixin calc($property, $expression, $fallback) {
#{$property}: #{$fallback};
#{$property}: -webkit-calc(#{$expression});
#{$property}: calc(#{$expression});
}
.example {
@include calc(width, '50% - 100px', 200px);
background: #ccc;
}
.example {
width: 200px;
width: -webkit-calc(50% - 100px);
width: calc(50% - 100px);
background: #ccc;
}
<div class="example">Calc Test</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment