4-2作业问题
老师给的批复是@keyframes可以只定义一次,但是定义一次的话我做不到示例里的效果.就是一开始的时候云的定位并不是一样,好比有的云动画开始时是在right:20%的位置,有的是right:10%,有的是right:25%.如果我这样写,那每朵云在动画开始时都是从最右边飘出的,即使我把每朵云都定位了也是没有效果的,以下是部分代码
div.cloud.c2 {
top: 35%;
right: 20%; //即使我定义了云的位置,但是云仍然是从最右边开始飘出
opacity: 0.6;
-webkit-transform: scale(0.6);
-moz-transform: scale(0.6);
-ms-transform: scale(0.6);
-o-transform: scale(0.6);
transform: scale(0.6);
-webkit-animation: cloudmove 7s linear infinite;
-moz-animation: cloudmove 7s linear infinite;
-ms-animation: cloudmove 7s linear infinite;
-o-animation: cloudmove 7s linear infinite;
animation: cloudmove 7s linear infinite;
}
@keyframes cloudmove {
0% {
right: -10%;
}
100% {
right: 110%;
}
}99
收起
正在回答 回答被采纳积分+1
2回答
洋葱宝宝
2017-06-02 20:40:19
/*白云*/
div.cloud.c1 {
top: 20%;
right: 10%;
opacity: 0.8;
-webkit-transform: scale(0.8) translateX(-50%);
-moz-transform: scale(0.8) translateX(-50%);
-ms-transform: scale(0.8) translateX(-50%);
-o-transform: scale(0.8) translateX(-50%);
transform: scale(0.8) translateX(-50%);
-webkit-animation: cloudmove 6s linear infinite;
-moz-animation: cloudmove 6s linear infinite;
-ms-animation: cloudmove 6s linear infinite;
-o-animation: cloudmove 6s linear infinite;
animation: cloudmove 6s linear infinite;
}
div.cloud.c2 {
top: 35%;
opacity: 0.6;
-webkit-transform: scale(0.6) translateX(-250%);
-moz-transform: scale(0.6) translateX(-250%);
-ms-transform: scale(0.6) translateX(-250%);
-o-transform: scale(0.6) translateX(-250%);
transform: scale(0.6) translateX(-250%);
-webkit-animation: cloudmove 7s linear infinite;
-moz-animation: cloudmove 7s linear infinite;
-ms-animation: cloudmove 7s linear infinite;
-o-animation: cloudmove 7s linear infinite;
animation: cloudmove 7s linear infinite;
}
/*白云动画*/
@-webkit-keyframes cloudmove {
0% {
right: -10%;
}
100% {
right: 110%;
}
}
@-moz-keyframes cloudmove {
0% {
right: -10%;
}
100% {
right: 110%;
}
}
@-ms-keyframes cloudmove {
0% {
right: -10%;
}
100% {
right: 110%;
}
}
@-o-keyframes cloudmove {
0% {
right: -10%;
}
100% {
right: 110%;
}
}
@keyframes cloudmove {
0% {
right: -10%;
}
100% {
right: 110%;
}
}测试下来感觉这个方法是可行的,不过不知道是不是最优的.
HTML5与CSS3实现动态网页 2018
- 参与学习 1887 人
- 提交作业 4643 份
- 解答问题 5760 个
有HTML和CSS基础,却不知道如何进阶?本路径带你通过系统学习,完成从“会做网页”到“做出好的动态网页”的蜕变,迈出成为前端工程师的第一步。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星