【发布时间】:2012-11-19 09:30:18
【问题描述】:
有这个 CSS3 代码:
#box1
{
position: relative;
width: 300px;
border: 1px solid black;
box-shadow: -3px 8px 34px #808080;
border-radius: 20px;
box-shadow: -8px 5px 5px #888888;
right: 700px;
top: -200px;
height: 150px;
}
@-webkit-keyframes myfirst {
0% { right:700px; top:-200px;background: yellow;}
50% {background:blue; right:700px; top:200px;}
100% { right:700px; top:-200px; background: yellow}
}
#stam {
font-size: large;
background: green;
width: 100px;
top: 400px;
position: absolute;
}
#stam:hover ~ #box1 { -webkit-animation:myfirst 2s; }
您可以在此处查看代码的工作原理:http://jsfiddle.net/FLe4g/2/
我的问题是:我该如何制作动画,所以当我将鼠标放在“stam”div 上时,动画将在动画的“50%”( 50% {background:blue; right:700px; top:200px;}) 处停止,并且只有当我将鼠标从“stam”移动时“div,动画继续吗?我真的更喜欢使用 CSS3 而不是 js 的解决方案...谢谢!
【问题讨论】:
-
嗨,我的演示工作(尝试将鼠标放在数字上)现在可以工作了吗?
-
不工作,我认为你做了广泛的区域,使位置可以在 jsfiddle 中使用
-
请试试这个,它最有效...jsfiddle.net/FLe4g/9
-
jsfiddle.net/oceog/FLe4g/10 我只能得到这个
-
非常感谢!它有效!
标签: css animation hover css-transitions