Bootstrap buttons get “stuck” down on mobile devices

后端 未结 2 1920
小蘑菇
小蘑菇 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;
    }
    
    0 讨论(0)
  • 2020-12-30 07:50

    If you are just developing for mobile then you could simply override the hover css altogether, for example:

    .btn:hover {
        background-color: inherit;
    }
    
    0 讨论(0)
提交回复
热议问题