简体   繁体   English

更改不同移动浏览器的悬停设置?

[英]Change hover settings for different mobile browsers?

I've got a website that utilizes :hover effects in the navbar & body. 我有一个网站,在导航栏和正文中使用:hover效果。

Using the mobile version of Safari on i-devices, hover events become "double-tap" events: one tap to display what would normally appear when 'hovering', and a second tap to 'click' the link. 在智能设备上使用Safari的移动版本时,悬停事件变为“双击”事件:一次轻击以显示“悬停”时通常会显示的内容,另一次轻击以“单击”链接。 This feature is useful for certain things... displaying a text dropdown on a thumbnail image, for instance, but annoying when selecting a navbar link. 此功能对某些事情很有用...例如在缩略图上显示文本下拉列表,但是在选择导航栏链接时很烦人。

On my android device using Chrome, the opposite occurs by default: Hover effects are simply ignored, no double click, nadda. 在使用Chrome的android设备上,默认情况下会发生相反的情况:悬停效果将被忽略,无需双击,使用nadda。

How might I modify the default ":hover becomes 'double-click' " behavior for specific objects on mobile versions of safari, while "adding" that functionality for android users? 在为Safari用户“添加”该功能时,如何修改Safari的移动版本上特定对象的默认“:hover变成'双击'”行为?

I don't know the exact setup of your coding, but there are several options you have. 我不知道您的编码的确切设置,但是您有几种选择。

First of all instead of browser or OS detection it is better to use feature detection (if possible), because feature detection will work for every setup instead for specific browsers or OS'. 首先,最好使用功能检测 (如果可能的话),而不是浏览器或OS检测,因为功能检测将适用于每种设置,而不适用于特定的浏览器或OS。 There are some frameworks out there you can use like modernizr . 您可以使用诸如modernizr之类的一些框架。

Another way to deal with things like this is to use CSS Hacks that only apply if it's the specific device/browser/OS. 处理此类问题的另一种方法是使用仅适用于特定设备/浏览器/操作系统的CSS Hacks You will find hundreds of CSS Hacks in the net. 您会在网上找到数百个CSS Hack。

There are other ways to detect the browser/OS like the user agent string, for solutions going in this direction I can recommend this question How to detect Safari, Chrome, IE, Firefox and Opera browser? 还有其他检测浏览器/操作系统的方法,例如用户代理字符串,对于朝这个方向发展的解决方案,我可以推荐这个问题。 如何检测Safari,Chrome,IE,Firefox和Opera浏览器? and Detecting iOS / Android Operating system . 检测iOS / Android操作系统

What really fits your use case best, you have to decide yourself, but this are the options I suggest. 最适合您的用例的是什么,您必须自行决定,但这是我建议的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM