Can I have an onclick effect in CSS?

后端 未结 12 1753
悲&欢浪女
悲&欢浪女 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:33

    I had a problem with an element which had to be colored RED on hover and be BLUE on click while being hovered. To achieve this with css you need for example:

    h1:hover { color: red; } 
    h1:active { color: blue; }
    
    

    This is a heading.

    I struggled for some time until I discovered that the order of CSS selectors was the problem I was having. The problem was that I switched the places and the active selector was not working. Then I found out that :hover to go first and then :active.

提交回复
热议问题