With the latest version of Modernizr, you can check csscalc support. Just use Modernizr.csscalc. This function will return true if it is supported, and false if it is not. In your case, you will have this in your css:
#abc { width:calc(100% - 20px); }
and in your javascript (here i am using jQuery)
if(!Modernizr.csscalc){ $('#abc').width($(PARENT_EL).width() - 20) }
BTW. Itβs better to style your elements with class names rather than identifiers. The item id should only be used to target it through javascript.
Benjamin Oct 22 '13 at 9:53 on 2013-10-22 09:53
source share