html - 尽管仅在正常状态下指定,为什么转换仍适用于活动状态
问题描述
我应用于正常状态的转换正在应用于活动状态的箭头。请注意,单击按钮时,箭头.3s
会从白色变为与其余活动状态相同的颜色。如何从箭头的活动状态中删除此转换,同时保持悬停按钮背景的转换?
我尝试从中删除transition: all .3s
,.btn
但这也删除了悬停状态背景颜色延迟。我想保留这个。
body {
background: #00b894;
}
.btn {
color: #fff;
padding: 0 60px;
height: 64px;
border: 3px solid #fff;
line-height: 58px;
background: none;
display: inline-block;
position: relative;
overflow: hidden;
outline: none;
transition: all .3s;
/* This is causing a transition on the arrow's active state */
}
.btn:hover {
background: #009E7E;
}
.btn:active {
border-color: #008066;
color: #008066;
}
.btn:before {
position: absolute;
transition: all 0.3s;
top: 50%;
transform: translateY(-50%);
}
.btn--continue:before {
left: 130%;
}
.btn--continue:hover:before {
left: 80%;
}
.icon-arrow-right:before {
content: "→";
}
<button class="btn btn--continue icon-arrow-right">Continue</button>
我希望白色箭头立即变成与其余活动状态相同的颜色。基本上,删除 .3s 过渡。但是,我想保持悬停按钮背景延迟。
解决方案
将您的过渡设置为:transition: background .3s;
推荐阅读
- c# - 如何限制从 .net 核心中的 Web API 修改某些属性?
- r - 为什么 gl_speech 在使用 for 循环时会返回错误,而不是针对每个单独的文件?使用 tryCatch
- python - Python Discord Bot“无法连接到主机”-保持离线状态
- javascript - 通过 Telegram 机器人打印 Google 数据表单元格,打印从单元格中获取的图像作为链接参考
- ios - SwiftUI iOS 14.2 beta,大中型主屏幕小部件中的文字消失?
- typescript - 将类型保护封装到函数中
- amazon-web-services - 如何在一个账户中使用 AWS AppSync 访问另一个账户中的 DynamoDB?
- linux - 在不使用 SSH 的情况下访问远程 Linux 服务器上的 Web UI
- node.js - EMR 集群历史记录的限制?
- c++ - 首次读取后程序执行未在 scanf() 处停止