sav*_*son 6 css google-chrome css-selectors
正如此 jsbin 中所示,我可以使用伪选择器设置单选按钮标签的样式:active。但是当我用空格键激活单选按钮时,与鼠标单击有关,之后不会释放活动状态。
任何人都可以向我解释这一点吗?Firefox 和 Edge 的处理方式似乎不同。
body {
font-family: sans-serif;
}
input:active + label {
background-color: red;
}Run Code Online (Sandbox Code Playgroud)
<p>When a radio button in this group is :active the label background is red.</p>
<p>Works as expected when clicking (the radio button gets "deactivated" again when the mouse button is released).</p>
<p>But if I activate a radio button with the keyboard, key [Space], it <i>isn't</i> deactivated on key up. I can then move to another radio button with the arrow keys (= that button is checked).</p>
<p>Again, I can hit [Space] and now I have <i>two</i> radio buttons in active state.</p>
<p>If I use the arrow keys to navigate to one of these active radio buttons, <i>then</i> it gets deactivated.</p>
<input type="radio" id="huey" name="drone" value="huey" checked>
<label for="huey">Huey</label>
<input type="radio" id="dewey" name="drone" value="dewey">
<label for="dewey">Dewey</label>
<input type="radio" id="louie" name="drone" value="louie">
<label for="louie">Louie</label>
<p><br>Another group with only one button – same issue:</p>
<input type="radio" id="jonna" name="jonne" value="jonna">
<label for="jonna">Jonna</label>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
77 次 |
| 最近记录: |