backgroundPositionX not working on Firefox

前端 未结 6 1775
感情败类
感情败类 2020-12-10 10:33

I have play with youtube\'s sprite animation but there is a problem. backgroundPositionX won\'t work under Firefox (but works on Chrome and IE8)... This is the

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-10 10:35

    You can do something like this

    First install jquery migration

    https://github.com/jquery/jquery-migrate/#readme

    Include these on your html

    The $.browser property allows you to target browsers you want to apply your style into

    In this case for background-position can be changed to property supported backgroundPosition

    Available flags are - webkit - safari - opera - msie (for IE) - mozilla

    Example for IE or Firefox

    if ( $.browser.msie || $.browser.mozilla) {
            $(".element").css('backgroundPosition', position + "px 0");                
    }
    

    for chrome

    if ( $.browser.webkit) {
            $(".element").css('backgroundPosition', position + "px 0");                
    }
    

    I got mine working and for all IE

    Cheers

提交回复
热议问题