How do I simulate a hover with a touch in touch enabled browsers?

后端 未结 14 2065
旧巷少年郎
旧巷少年郎 2020-11-22 17:04

With some HTML like this:

Some Text

Then some CSS like this:

p {
  color:black;
}

p:hover {
  color:red         


        
14条回答
  •  孤城傲影
    2020-11-22 17:31

    Try this:

    
    

    And in your CSS:

    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*/
    }
    

    With this code you don't need an extra .hover class!

提交回复
热议问题