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

后端 未结 14 2061
旧巷少年郎
旧巷少年郎 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:41

    Use can use CSS too, add focus and active (for IE7 and under) to the hidden link. Example of a ul menu inside a div with class menu:

    .menu ul ul {display:none; position:absolute; left:100%; top:0; padding:0;}
    .menu ul ul ul {display:none; position:absolute; top:0; left:100%;}
    .menu ul ul a, .menu ul ul a:focus, .menu ul ul a:active { width:170px; padding:4px 4%; background:#e77776; color:#fff; margin-left:-15px; }
    .menu ul li:hover > ul { display:block; }
    .menu ul li ul li {margin:0;}
    

    It's late and untested, should work ;-)

提交回复
热议问题