如何增加CSS中:active的持续时间? [英] How to increase the duration of :active in css?

查看:283
本文介绍了如何增加CSS中:active的持续时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,希望绿色背景颜色保持比被按下的按钮更长的时间.有可能吗?

So want the green background color to stay longer than the button being pressed. Is it possible?

#button {
  background-color: red;
  width: 100px;
  height: 50px;
  display: block;
}
#button:active {
  background-color: green;
}

<!DOCTYPE html>

<html lang="en">

<head>
  <meta charset="utf-8" />
  <title></title>

</head>

<body>
  <a href="#" id="button">1</a> 

</body>

</html>

推荐答案

可以使用transition

#button {
  background-color: red;
  width: 100px;
  height: 50px;
  display: block;
  transition:0s 1s;
}
#button:active {
  background-color: green;
  transition:0s;
}

<!DOCTYPE html>

<html lang="en">

<head>
  <meta charset="utf-8" />
  <title></title>

</head>

<body>
  <a href="#" id="button">1</a> 

</body>

</html>

这篇关于如何增加CSS中:active的持续时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆