css“:active”右键单击,与浏览器实现不一致 [英] css ":active" with right click, inconsistencies with browser implementation

查看:289
本文介绍了css“:active”右键单击,与浏览器实现不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




      我只注意到浏览器在右键单击时处理css:active状态的方式不一致
    • Safari 5& IE 10::active被触发,元素保持:active,直到上下文菜单关闭



    下面是一个快速jsfiddle =http://jsfiddle.net/annam/tqBqV/ =nofollow> http://jsfiddle.net/annam/tqBqV/

      div {background:red; } 
    div:active {background:green; }

    任何人都知道哪个是正确的行为?我想没有办法标准化。

    解决方案

    选择器3 表示:active 元素被激活,并且进一步定义通过诸如鼠标之类的指点设备的激活,当按下主按钮时:



    • 当用户激活元素时,应用:active 伪类。例如,在用户按下鼠标按钮并释放它的时间之间。在具有多个鼠标按钮的系统上,:active 仅适用于主要或主要激活按钮(通常为左鼠标按钮)及其任何别名。 li>

    如果辅助点击激活了:active ,则该浏览器违反了规范(除非浏览器声明仅实现 CSS2.1 ,其中这个限制是不是设置的,但是对于给定的任何浏览器都不是这样)。


    I just noticed an inconsistency between the way browsers handle the css :active state of an element when it is right-clicked (contextmenu click)

    • Firefox: :active is not triggered
    • Chrome: :active is triggered momentarily, until mouseup occurs
    • Safari 5 & IE 10: :active is triggered and element remains :active until the contextmenu is closed

    Here's a quick jsfiddle to replicate this http://jsfiddle.net/annam/tqBqV/

    div { background: red; }
    div:active { background: green; }
    

    Anyone knows which is the correct behaviour? I guess there is no way to standardize?

    解决方案

    Selectors 3 says :active is true when an element is being activated, and further defines activation via a pointing device such as a mouse to be when the primary button is pressed:

    • The :active pseudo-class applies while an element is being activated by the user. For example, between the times the user presses the mouse button and releases it. On systems with more than one mouse button, :active applies only to the primary or primary activation button (typically the "left" mouse button), and any aliases thereof.

    If a secondary click activates an element for the purposes of :active in a particular browser, then that browser is in violation of the spec (unless the browser claims only to implement CSS2.1, where this restriction is not set in stone, but that's not true for any of the browsers given).

    这篇关于css“:active”右键单击,与浏览器实现不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆