【问题标题】:how to keep hover effect after clicking button and moving cursor away单击按钮并将光标移开后如何保持悬停效果
【发布时间】:2021-11-10 10:14:58
【问题描述】:

我有一个按钮,我在 CSS 中设置样式。我在按钮上有悬停效果,效果很好。但是,如果我单击按钮并将光标移开然后再次返回,则悬停效果将丢失。如何在 css 中解决这个问题?

【问题讨论】:

  • 查看这个问题的答案:stackoverflow.com/questions/13630229/…
  • 你能把你的那部分代码提供给我们吗?
  • 请提供足够的代码,以便其他人更好地理解或重现问题。

标签: css button hover


【解决方案1】:

如果我理解正确,您可以通过将转换移动到链接而不是悬停状态来做同样的事情:

    ul li a {
    color:#999;       
    transition: color 0.5s linear; /* vendorless fallback */
    -o-transition: color 0.5s linear; /* opera */
    -ms-transition: color 0.5s linear; /* IE 10 */
    -moz-transition: color 0.5s linear; /* Firefox */
    -webkit-transition: color 0.5s linear; /*safari and chrome */
}

ul li a:hover {
    color:black;
    cursor: pointer;
}

see this demo

【讨论】:

    猜你喜欢
    • 2015-08-21
    • 2015-04-13
    • 1970-01-01
    • 2013-08-28
    • 2015-05-15
    • 1970-01-01
    • 2013-02-05
    • 2013-10-24
    • 1970-01-01
    相关资源
    最近更新 更多