触发“:active”触摸屏上的伪类
我目前正在开发一个 JavaScript 应用程序,该应用程序将部署在以 kiosk 模式运行 Chrome 的触摸屏 kiosk 上。
我注意到,当我使用鼠标单击界面上的按钮时,“:active”伪类应用的样式在鼠标按下时可见。我的问题是,通过触摸屏幕触发的同一按钮不会触发活动状态。
有没有办法让触摸事件的行为与鼠标单击相同?
I'm currently developing a JavaScript application which will be deployed on a touchscreen kiosk running Chrome in kiosk mode.
I've noticed that when I use a mouse to click the buttons on the interface, the styles applied by the ":active" pseudo class is visible when the mouse is down. My problem is that the same button triggered by touching the screen does not trigger the active state.
Is there a way to make a touch event behave the same way as a mouse click?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设 CSS :active 伪类不起作用,您可能需要使用 DOM 事件。
“mousedown”和“mouseup”事件适用于触摸屏吗?假设他们这样做,你可以尝试这样的事情:
然后在你的 CSS 中,将 :active 替换为 [data-active],如下所示:
我不认为这会完全一样......你可能需要做一些技巧例如,让子元素正常工作。
Assuming the CSS :active pseudo-class isn't working, you'll probably need to use DOM events.
Do the "mousedown" and "mouseup" events work with touchscreens? Assuming they do, you could try something like this:
Then within your CSS, replace :active with [data-active], like so:
I don't think this will work quite the same... you may need to do some trickery to get child elements to work correctly, for instance.