Changing the background colour of an active input selector

前端 未结 2 1652
时光取名叫无心
时光取名叫无心 2021-01-19 17:42

Any reason why when I run this code,

input[type=submit]:active {
  background-color: green;
}

when I click the desired button it only flash

2条回答
  •  心在旅途
    2021-01-19 18:23

    You also need to use the :focus selector.

    This then adds the background color to the input as it is the focused element.

    input[type=submit]:active, input[type=submit]:focus {
      background-color: green;
    }

提交回复
热议问题