Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Handling a submenu on hover in mobile devices

Featured Replies

Hi WDF,

 

I've got a submenu that is visible on hover and I'm wondering what's the best practise to make this usable on mobile devices?

 

I could use media queries to display it if width < x but as mobile screen sizes grow and grow, it could get to a point where you could be on a mobile device with a desktop resolution so the media query wouldn't work.

 

I could also use detect what browser they're on but again, this isn't bulletproof. A new device could come out with a new browser that I've not accounted for and again it wouldn't display.

 

So what've you done in this situation?

 

It's probably not an option to just have it displayed always, even on desktop.

 

Cheers,

~evu.

  • Author

Hi BD,

 

How does that work? The sub menu handle is a link in itself, so clicking that would just load that page.

 

I'm surprised I can't seem to find the answer on Google :/

 

Cheers,

~evu.

  • Author

Well, I figured it out. I hope.

 

//if touch enabled, add "touch" class to html tag
function isTouchDevice(){
if (typeof(window.ontouchstart) != 'undefined') {
 $('html').addClass('touch');
}
}
//run touch test
isTouchDevice();

 

So, if it's a touch enabled device, all you have to do is preceed the associated styles with ".touch".

 

Super small and super easy :)

 

Shame I don't have a lot of devices to test on but so far on S3 and Iphone 4 it works.

 

~evu.

Edited by evu

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.