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 click another element. This is not the active class being applied to an element.
It's subtle but very annoying, especially when I try to apply styles to the button they dont show up until i click on a different element.
Try going to http://twitter.github.com/bootstrap/base-css.html#buttons on a mobile device and click a button you'll see what i mean
I tried triggering all sorts of events with jquery but nothing worked, this is a snippet i have at the END of my javascript
$(document).on('tapclick', '.btn', function() {
$(this).blur();
$(this).trigger('mouseup');
});
and tried overriding css stylings on hover
.btn a:hover,.btn a:link,.btn a:visited,.btn a:active{
text-decoration: none !important;
cursor: default !important;
background-color: transparent !important;
background-image: none !important;
}
If you are just developing for mobile then you could simply override the hover css altogether, for example:
.btn:hover {
background-color: inherit;
}
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With