单击了< button>的CSS伪类. [英] CSS pseudo-class for having clicked on a <button>
问题描述
似乎:active
仅在您单击中间的< button>
时立即应用背景
颜色在两次点击释放之间.我基本上想应用一个伪类(如果存在),该伪类在释放< button>
元素的单击后释放,以向查看者证明它已被切换.
It seems that :active
only applies a background
color at the instant when you have clicked on the <button>
in the interim between click release. I basically would like to apply , if it exists, a pseudo-class that is invoked after the release of a click on a <button>
element to demonstrate to the viewer that it has been toggled.
button:active{
background:#FFFFFF;
}
更新:
我将< button>
更改为锚标记.但是,当我尝试
I changed the <button>
to be an anchor tag. However, when I try
#button-id:visited{ background:#FFFFFF; }
单击< a>
这是小提琴:
https://jsfiddle.net/y5apt5et/
推荐答案
Here's a list of all CSS pseudo-classes. There's nothing that works as a toggle button. Your best bet is to add an event listener that listens for a click on the button and adds or removes a class that represents being toggled.
这篇关于单击了< button>的CSS伪类.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!