Is there a css selector that I can select an input of type submit only when it is triggered / clicked

2

My question is as follows:

Is there any way to just select a css tag with css only when it is clicked / clicked.

    
asked by anonymous 06.12.2018 / 21:29

2 answers

5

When you click on the input, it receives the status of :focus :

input[type=submit]:focus {
  color: red;
}
  

Editing: As reported in Hugo's response, :active occurs when button is clicked. :focus may occur   when the button is clicked, via TAB key or via script.

When the focus is removed it returns to the original state.

Example:

input[type=submit]:focus {
  color: red;
}
<input type="submit">
    
06.12.2018 / 21:34
4

I think I understood the question differently, I believe he wants to "fire" some property on the click. And in that case it would be with :active

Hereisthecodefortheimageabove:

[type="submit"]:active {
    box-shadow: none;
    transition: box-shadow 100ms;
}
[type="submit"]:active {
    box-shadow: 0 0 20px red;
}
<input type="submit" value="Clique aqui">

OBS

Any element can receive a :active

  

The% pseudo-class is also typically matched when using the keyboard key tab. It is frequently used on :active and <a> HTML elements, but may not be limited to just those

The pseudo-class <button> is also commonly used when using the keyboard tab key. It is often used in HTML elements :active and <a> , but may not be limited just them. "

Source: link

    
06.12.2018 / 21:44