这里我有一个基于鲍文斯氏回答要选择任何可聚焦的HTML元素,请执行以下操作:a[href]:not([tabindex='-1']),
area[href]:not([tabindex='-1']),
input:not([disabled]):not([tabindex='-1']),
select:not([disabled]):not([tabindex='-1']),
textarea:not([disabled]):not([tabindex='-1']),
button:not([disabled]):not([tabindex='-1']),
iframe:not([tabindex='-1']),
[tabindex]:not([tabindex='-1']),
[contentEditable=true]:not([tabindex='-1'])
{
/* your CSS for focusable elements goes here */
}
或者更漂亮一点:a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),
iframe,[tabindex],[contentEditable=true]{
&:not([tabindex='-1'])
{
/* your SCSS for focusable elements goes here */
}}
我增加了它作为一个答案,因为这是,我正在寻找的,当谷歌重定向我到这个堆栈溢出的问题。
编辑:还有一个可聚焦的选择器:[contentEditable=true]
然而,这是很少使用的。