Bootstrap buttons get “stuck” down on mobile devices

后端 未结 2 1938
小蘑菇
小蘑菇 2020-12-30 07:02

Whenever I click a button with my mobile device (android) on a twitter boostrap button but button gets odd styling like the mouse is still over and doesn\'t release until I

2条回答
  •  星月不相逢
    2020-12-30 07:39

    I fixed this problem by adding a class to the button on the touchend event and then overriding the default bootstrap background position.

    javascript:

    $("button").on("touchstart", function(){ 
        $(this).removeClass("mobileHoverFix");
    });
    $("button").on("touchend", function(){ 
        $(this).addClass("mobileHoverFix");
    });
    

    css:

    .mobileHoverFix:hover,
    .mobileHoverFix.hover{
        background-position: 0 0px;
    }
    

提交回复
热议问题