Recreating the HTML5 range input for Mobile Safari

2019-01-23 08:57发布

So I've been working on a HTML5 iPad application for work and have come across a problem. I didn't have access to an iPad whilst first working on this app and relied on desktop Safari to get my app quickly together (probably not the best thing, anyhow...)

I'm having to rely on a input range for a part of the interface. After seeing that HTML5 had a range input, I was happy as this is just what I needed. I even managed to style it up to exactly what was designed:

HTML5 range input

This is great! ...until I actually tried it on an iPad and it doesn't work. Just shows a text input. I'm now wondering what to do... I do need a slider, something that when dragged, it spits out the data. Obviously needs to work with touch. After looking around all over the web, there doesn't seem to be a solid solution.

What do you guys suggest here? What's the proper way of coding up a working touch-friendly slider, just like the native HTML5 one that it doesn't support!?

Any ideas/thoughts/knowledge/experience would be greatly appreciated! James

7条回答
女痞
2楼-- · 2019-01-23 09:45

An easy and quick SOLUTION!

The input range slider can be made User-Friendly on a mobile device by removing the troublesome highlight effect on the slider when tapped upon.

The Fix - Add the CSS property, -webkit-tap-highlight-color: transparent to the CSS of the element or the complete html page. This will remove the highlight effect on an element when it is tapped on a mobile device.

查看更多
登录 后发表回答