【问题标题】:How to change tab key selection color with css? [duplicate]如何用css更改tab键选择颜色? [复制]
【发布时间】:2016-10-03 12:04:06
【问题描述】:

当我按 Tab 键并选择一个按钮时,它会得到一个边框。是否可以使用 css 更改其颜色或完全去除边框?

【问题讨论】:

  • 您可以使用outline: none,它会修复它,但我敦促您保持原样(除非您有其他明显的区别),因为可能有些用户没有使用鼠标和这个轮廓会让他们知道哪个项目被聚焦。看看这个 - outlinenone.com
  • 是的,您可以在 css 中覆盖 :focus:active 样式。
  • 谢谢,outline:none 工作正常

标签: css


【解决方案1】:
<!DOCTYPE html>
<html>
<head>
<style>
input:focus {
    background-color: yellow;
}
</style>
</head>
<body>

<p>Click inside the text fields to see a yellow background:</p>

<form>
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname">
</form>

<p><b>Note:</b> For :focus to work in IE8, a DOCTYPE must be declared.</p>

</body>
</html>

【讨论】:

  • 不鼓励使用纯代码答案。
猜你喜欢
  • 2016-03-21
  • 1970-01-01
  • 1970-01-01
  • 2021-09-06
  • 1970-01-01
  • 2017-04-29
  • 2023-03-11
  • 2010-10-21
  • 1970-01-01
相关资源
最近更新 更多