Matt Radford

Messing with links since <blink>

LESS mixin to calculate a width

Published on 

A LESS mixin to calculate a width with a defined margin, vendor prefixed. Add a fallback in absolute size or %.

.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 */
}
view raw .calc-width hosted with ❤ by GitHub