【发布时间】:2015-01-29 00:28:29
【问题描述】:
我一直在查看一些网站的代码,并注意到边距大小会根据某些操作(例如,鼠标悬停、屏幕宽度)而变化,以创建很酷的动态效果。 更改屏幕宽度时可以在此处看到此效果: http://www.smashbros.com/us/
鼠标悬停在这里: http://www.disneyanimation.com/projects
我真的不知道这是怎么做到的! 代码值如何根据某些操作自动更改。
提前致谢
编辑:
我尝试了一些东西....但它并没有真正给我想要的结果
.cats {
background-color: #eee;
height: 90px;
width: 100%;
}
.cats {
-webkit-animation-duration: 0.5s;
-webkit-animation-name: slide-up;
-moz-animation-duration: 0.5s;
-moz-animation-name: slide-up;
}
.cats {
-webkit-animation: slide-up 0.5s linear;
-moz-animation: slide-up 0.5s linear;
-webkit-animation-play-state: paused;
-moz-animation-play-state: paused;
}
.cats :hover {
/* Toggle the animation play state to running when we are hovering over our sticker */
-webkit-animation-play-state: running;
-moz-animation-play-state: running;
}
@-webkit-keyframes slide-up {
from {
margin-top: 0px
}
to {
margin-top: -15px
}
}
【问题讨论】:
-
你需要自己动手;但首先尝试找到一些关于如何从 HTML 和 CSS 开始的教程。然后,一旦你开始,并开始理解选择器和伪类的语法,它就开始有意义了。并且变得可以理解,并且奇怪地引人注目和令人上瘾。
-
谢谢!我已经编码了一段时间,但从未真正探索过动画。我在编辑中尝试了一些东西......我在正确的轨道上吗?哈哈