
比如做个工具栏按钮,点了之后按钮会一直灰色,除非再点一下页面空白地方,太丑了!
<meta name="viewport" cOntent="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <style> .btn { padding: 1em; font-size: xx-large; } .btn { background: #fff; border: 1px solid #777; } .btn:hover { background: #ddd; } .btn:focus { outline: green solid 5px; } .btn:active { color: red; } </style> <div id="root"> <button class="btn" id=btn1>Click Me</button> <button class="btn">Click Me 2</button> </div> <script> btn1.Onclick= function (e) { e.target.blur() } </script> 1 oul 2019 年 5 月 14 日 :hover 是给鼠标用的,如果想要实现类似效果,可以使用 touch 事件来模拟。 |