Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding Bootstrap Tooltips on Mobile using Media Queries

I am using Bootstrap's Tooltips over buttons on my site but when viewed on a mobile device, these tooltips are triggered on the first click, meaning I have to double click on the button. I want to prevent these being shown on mobile devices and have tried using media queries to do so. My code has been:

@media only screen  and (min-device-width : 768px)  and (max-device-width : 1024px)  {  .tooltip  {   display: none;  } } 

This stops the tooltip from displaying, but I still have to click twice to get the button to function. Is there any way I can prevent these tooltips from firing using media queries?

like image 575
natlines Avatar asked Aug 10 '12 13:08

natlines


People also ask

What are the four options for how a tooltip is triggered?

How tooltip is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. 'manual' indicates that the tooltip will be triggered programmatically via the .

Are Bootstrap tooltips accessible?

As you may know, the Twitter bootstrap tooltips are not accessible (I.E. they are not being read by screen readers).

How do I change the tooltip position in bootstrap?

How to position the tooltip - auto | top | bottom | left | right. When auto is specified, it will dynamically reorient the tooltip. When a function is used to determine the placement, it is called with the tooltip DOM node as its first argument and the triggering element DOM node as its second.


2 Answers

I have achieved it differently; Mobile and other devices are touch enabled, so I checked if it's touch device or not.

function isTouchDevice(){     return true == ("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch); } 

Now, check if it's not a touch device to trigger the tool-tip:

if(isTouchDevice()===false) {     $("[rel='tooltip']").tooltip(); } 
like image 114
Aamir Shahzad Avatar answered Sep 20 '22 18:09

Aamir Shahzad


Just use the !important flag since the tooltip position is styled inline.

@media only screen  and (min-device-width : 768px)  and (max-device-width : 1024px) {     .tooltip {         display: none !important;     }  } 
like image 37
TotPeRo Avatar answered Sep 21 '22 18:09

TotPeRo