No es tan difícil de replicar en javascript :-), aunque sólo funcionará para la anchura y la altura de los mejores, pero se puede expandirlo según sus expectativas :-)
function calcShim(element,property,expression){
var calculated = 0;
var freed_expression = expression.replace(/ /gi,'').replace("(","").replace(")","");
// Remove all the () and spaces
// Now find the parts
var parts = freed_expression.split(/[\*+-\/]/gi);
var units = {
'px':function(quantity){
var part = 0;
part = parseFloat(quantity,10);
return part;
},
'%':function(quantity){
var part = 0,
parentQuantity = parseFloat(element.parent().css(property));
part = parentQuantity * ((parseFloat(quantity,10))/100);
return part;
} // you can always add more units here.
}
for(var i = 0; i < parts.length; i++){
for(var unit in units){
if(parts[i].indexOf(unit) != -1){
// replace the expression by calculated part.
expression = expression.replace(parts[i],units[unit](parts[i]));
break;
}
}
}
// And now compute it. though eval is evil but in some cases its a good friend.
// Though i wish there was math. calc
element.css(property,eval(expression));
}
uso de esta manera con jQuery $ ('# DataElement') css ({ 'width': 'calc (100% -100px)'}).; –