Home  >  Article  >  Web Front-end  >  css的active事件在手机端不生效的解决方法_html/css_WEB-ITnose

css的active事件在手机端不生效的解决方法_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:32:311690browse

对一名前端来说,改页面的过程总是痛苦的,产品经理说要加个点击样式,于是加active的class,本来以为这样就OK了,没想到电脑上ok,本地测也是ok的,tomcat上一跑就没效果了。我甚至把! important也加上去了也没效果,于是就网上寻找答案,以下列出2种亲测有效的解决方法。

一个方法是把a原样式写上。

  <br />a{color: red;}a:hover{color: blue;}

但是这种方法对于后来加class的人就不方便了,其实还有一个更简便的方法:在body里加个空的ontouchstart。

<br /><body ontouchstart="">    ...</body><br /><br />没错,就是这么简单。如果还是没效果,你就试试在a标签里加ontouchstart。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn