为什么 a:active 伪类不起作用
我正在为某些网站使用CSS。我注意到我的 css 文件中的 a:active 样式定义根本不起作用。有人告诉我,我必须按照这个顺序放置定义,
a:link {...}
a:visited {...}
a:hover {...}
a:active {...}
我已经这样做了,但它仍然不起作用。请有人告诉我为什么它不起作用以及可能的解决方法。谢谢
Am using css for some site. I noticed that the a:active style definition in my css file does not work at all. I was told by someone that I have to put the definitions in this order
a:link {...}
a:visited {...}
a:hover {...}
a:active {...}
I have done so but it's still not working. Please could someone tell me why it is not working and a possible workaround. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是一个工作示例:
http://jsfiddle.net/BMHUz/
单击并按住锚标记,然后你会看到它变成橙色。
Here is a working example:
http://jsfiddle.net/BMHUz/
Click and hold on the anchor tag and you will see it turn orange.
a:active 只停留在您点击链接的几毫秒内。
请问您希望看到什么?如果您希望链接在该页面上具有不同的颜色,那不是 a:active 的用途
a:active just stay for the few milliseconds you are clicking the link.
May i ask what you expect to see? In case you want a link to be a different color if you are on that page, thats not what a:active is for
如果您希望链接在该页面上具有不同的样式,那么您需要使用 jquery 或 javascript 来更改活动链接的样式。
jQuery
CSS
If you want a link to be a different style if you are on that page, then you need to use jquery or javascript to change the style of active link.
jquery
CSS
如果已经定义到锚点,则将
!important
添加到属性中。Put
!important
to the property if it is already defined to the anchor.