【问题标题】:How can add style to a button on every mouse down?如何在每次鼠标按下时为按钮添加样式?
【发布时间】:2020-11-18 16:18:58
【问题描述】:

我有一个按钮,每次单击按钮时都想缩放(1.5), 现在我在 css 中使用 button:active 来缩放(1.5)我的按钮,但是这个命令只有一次运行,另一次我应该在按钮外部单击,然后单击按钮来缩放(1.5),我能做什么?请帮帮我

button:active {
  transform: scale(1.5);
  background-color: red;
}
<button type="button"> button</button>

【问题讨论】:

  • 这能回答你的问题吗? Onclick CSS button effect
  • 可能缺少某些东西,链接到按钮的 CSS 可以正常工作。
  • 当我用鼠标点击时,这是真的,但当我用笔记本电脑的垫子点击时,它不起作用

标签: javascript html css


【解决方案1】:
button {
  background: none;
}

button:active{
     transform: scale(1.5);
     background-color: red;
}

button:focus{
     transform: scale(1.5);
     background-color: red;
}

【讨论】:

  • 当我用鼠标点击时,这是真的,但当我用笔记本电脑的垫子点击时,它不起作用
  • 嗯,也许可以尝试使用 Javascript fr it
  • 如果你有 Jquery 试试
  • 有可能阅读我的答案
  • 我的项目是 react js,我可以使用 javascript,但我不知道鼠标垫如何实现此功能
猜你喜欢
  • 1970-01-01
  • 2017-11-21
  • 1970-01-01
  • 1970-01-01
  • 2013-06-07
  • 1970-01-01
  • 2015-05-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多