使用这样的HTML:<p>Some Text</p>然后是这样的CSS:p {
color:black;}p:hover {
color:red;}我如何允许长时间触摸允许触摸的设备复制悬停?我可以更改标记/使用JS等,但我想不出一个简单的方法来做到这一点。
3 回答

largeQ
TA贡献2039条经验 获得超7个赞
$(document).ready(function() { $('.hover').on('touchstart touchend', function(e) { e.preventDefault(); $(this).toggleClass('hover_effect'); });});
hover_effect
element:hover { rule:properties;}
element:hover, element.hover_effect { rule:properties;}
.hover {-webkit-user-select: none;-webkit-touch-callout: none; }

猛跑小猪
TA贡献1858条经验 获得超8个赞
$('body').on('touchstart', function() {});

达令说
TA贡献1821条经验 获得超6个赞
<script>document.addEventListener("touchstart", function(){}, true);</script>
element:hover, element:active {-webkit-tap-highlight-color: rgba(0,0,0,0);-webkit-user-select: none; -webkit-touch-callout: none /*only to disable context menu on long press*/}
添加回答
举报
0/150
提交
取消