Using css transform property in jQuery

前端 未结 5 594
广开言路
广开言路 2020-12-24 10:53

How can you specify cross-browser transform controls using jQuery since each browser seems to use its own methodology?

Here is the code I am using for Firefox but I

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-24 11:17

    If you want to use a specific transform function, then all you need to do is include that function in the value. For example:

    $('.user-text').css('transform', 'scale(' + ui.value + ')');
    

    Secondly, browser support is getting better, but you'll probably still need to use vendor prefixes like so:

    $('.user-text').css({
      '-webkit-transform' : 'scale(' + ui.value + ')',
      '-moz-transform'    : 'scale(' + ui.value + ')',
      '-ms-transform'     : 'scale(' + ui.value + ')',
      '-o-transform'      : 'scale(' + ui.value + ')',
      'transform'         : 'scale(' + ui.value + ')'
    });
    

    jsFiddle with example: http://jsfiddle.net/jehka/230/

提交回复
热议问题