Can I have an onclick effect in CSS?

后端 未结 12 1799
悲&欢浪女
悲&欢浪女 2020-11-21 06:42

I have an image element that I want to change on click.


This works:

#btnLeft:hover {
    width:7         


        
12条回答
  •  眼角桃花
    2020-11-21 07:15

    Edit: Answered before OP clarified what he wanted. The following is for an onclick similar to javascripts onclick, not the :active pseudo class.

    This can only be achieved with either Javascript or the Checkbox Hack

    The checkbox hack essentially gets you to click on a label, that "checks" a checkbox, allowing you to style the label as you wish.

    The demo

提交回复
热议问题