【问题标题】:how to disable hover affect when searchbox is focused?搜索框聚焦时如何禁用悬停效果?
【发布时间】:2021-03-02 22:49:56
【问题描述】:

我在我的网络中为搜索框输入了 CSS 代码。但是当它聚焦时,悬停仍然有效。如何在搜索框获得焦点时禁用此悬停效果并在焦点效果移除后再次启用它???

【问题讨论】:

  • 请提供您的代码。
  • 您需要先提供示例代码大纲,然后才能有人提供解决方案。

标签: javascript html css


【解决方案1】:

像这样将:not(:focus) 添加到您的选择器中:

input:hover:not(:focus) {
  color: red;
}
<input type="text" value="hover or click" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-26
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 2016-08-31
    • 2015-01-01
    • 2017-09-05
    相关资源
    最近更新 更多