使用 CSS3 过渡延迟鼠标移开/悬停
我有一个在悬停时会改变大小的盒子。但是,我想延迟鼠标移出阶段,以便框在恢复旧尺寸之前保持新尺寸几秒钟。
div {
width: 70px;
-webkit-transition: .5s all;
}
div:hover {
width:130px;
}
不使用 Javascript 而只使用 CSS3 是否可以做到这一点?我只需要关心支持webkit。
I've got a box that changes size when being hovered. However, I would like to delay the mouseout stage, so that the box keep the new size for a few seconds, before getting the old size back.
div {
width: 70px;
-webkit-transition: .5s all;
}
div:hover {
width:130px;
}
Is this possible to do WITHOUT Javascript and only CSS3? I only have to care about supporting webkit.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将立即触发鼠标悬停状态,但请等待 5 秒,直到触发鼠标悬停。
小提琴
This will trigger the mouseover state right away, but wait 5 sec till the mouseout is triggered.
Fiddle
转换可以声明为
(简写,第一个数字是持续时间,第二个数字是延迟)
那么你不需要单独的转换延迟
抱歉,无法添加为评论,因为我没有足够的点
transition can be declared as
(shorthand, the first number is duration, the second number is delay)
then you don't need the separate transition-delay
sorry, can't add as a comment as I don't have enough points