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

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

WBOY
Release: 2016-06-24 11:32:31
Original
1775 people have browsed it

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

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

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

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

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template