Configure all providers Prefix versions of "width: calc ..." Using jQuery?

I am working on using a project that uses jQuery and I need to dynamically set calc () based width using jQuery. The problem is that for the calculation to work, the CSS should look something like this:

CSS

width: -moz-calc(33% - 50px);
width: -webkit-calc(33% - 50px);
width: calc(33% - 50px);

When I try to use jQuery $(selector).css('width', 'calc(33% - 50px)'), I cannot set the width with multiple calc prefix versions. How can I handle multiple parameters of the same CSS property in jQuery to provide a provider prefix?

+5
source share
1 answer

Have you tried something like:

calc = "calc(33% - 50px)";

if ($.browser.webkit) {
  calc = "-webkit-"+calc;
}

$(selector).css('width',calc);
0
source

All Articles