Skip to content

Instantly share code, notes, and snippets.

@mattradford
Last active August 29, 2015 14:05
Show Gist options
  • Save mattradford/c04dcb12ddca2b7ca7ff to your computer and use it in GitHub Desktop.
Save mattradford/c04dcb12ddca2b7ca7ff to your computer and use it in GitHub Desktop.
LESS mixin to calculate a width
.calc-width(@margin, @fallback) {
width: @fallback;
width: -o-calc(~"100% - "@margin);
width: -webkit-calc(~"100% - "@margin); /** Safari 6, Chrome 19-25 **/
width: -moz-calc(~"100% - "@margin); /** FF 4-15 **/
width: calc(~"100% - "@margin); /** FF 16+, IE 9+, Opera 15, Chrome 26+, Safari 7 and future other browsers **/
/* See http://caniuse.com/#search=calc for known issues with calc */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment