更改活动输入选择器的背景颜色
Changing the background colour of an active input selector
为什么当我 运行 这段代码时,
input[type=submit]:active {
background-color: green;
}
当我点击所需的按钮时,它只闪烁绿色一秒钟,然后 returns 变成原来的颜色?我怎样才能让它永久保持绿色?
input[type=submit]:focus {
background-color: green;
}
试试这个
您还需要使用 :focus
选择器。
这会将背景色添加到输入中,因为它是焦点元素。
input[type=submit]:active, input[type=submit]:focus {
background-color: green;
}
<input type="submit" />
为什么当我 运行 这段代码时,
input[type=submit]:active {
background-color: green;
}
当我点击所需的按钮时,它只闪烁绿色一秒钟,然后 returns 变成原来的颜色?我怎样才能让它永久保持绿色?
input[type=submit]:focus {
background-color: green;
}
试试这个
您还需要使用 :focus
选择器。
这会将背景色添加到输入中,因为它是焦点元素。
input[type=submit]:active, input[type=submit]:focus {
background-color: green;
}
<input type="submit" />