【发布时间】:2014-06-03 22:24:47
【问题描述】:
我有一个要求,容器在整个页面上伸展。当我点击容器时,它应该会变小。
这应该发生在动画中。我尝试了将拉伸元素动画到顶部的 css 过渡:
- 在向右上角移动的同时缓慢缩小到提供的尺寸
但我想要的是
- 在中间收缩,然后通过动画移动到页面的右下角。
CSS
#main {
position: fixed;
height: 100%;
width: 100%;
margin-top: 50px;
background-color: red;
transition: all 0.5s ease;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
}
#click:hover + #main {
position: fixed;
width: 100px;
height: 50px;
margin-top: 50px;
background-color: green;
transition: all 0.5s ease;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
}
#click {
width: 100px;
height: 50px;
background-color: cornflowerblue;
color: white;
font-weight: bold;
text-align: center;
}
我应该怎么做?
【问题讨论】:
-
这是一个两步动画,您应该查看关键帧css-tricks.com/snippets/css/keyframe-animation-syntax
-
查看 CSS 转换。
-
@vico 对不起,我忘了说我也应该支持 IE9。
-
我猜你可以用 jquery add class 伪造第二步
-
@vico 你能提供解决方案吗?我不能使用 jquery,但可能我可以通过引用将它转换为 javascript。 :)
标签: javascript html css css-transitions