虽然效果实现了 但是感觉问题很多。请老师指导。小兔子位置我使用图块代替。不然您那边不显示兔子。

虽然效果实现了 但是感觉问题很多。请老师指导。小兔子位置我使用图块代替。不然您那边不显示兔子。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <link rel="stylesheet" href="css\animation.css" />
  </head>
  <body>
      <!-- 天空部分 -->
    <div class="sky">
        <!-- 1~5的云朵 -->
      <div class="cloud1"></div>
      <div class="cloud2"></div>
      <div class="cloud3"></div>
      <div class="cloud4"></div>
      <div class="cloud5"></div>
    </div>
    <!-- 草坪部分 -->
    <div class="land">
      <!-- <div class="rabbit"><img src="img\rabbit.png" alt="这是小兔子" /></div> -->
      <div class="rabbit">这是小兔子</div>
    </div>
  </body>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
* {
  margin0;
  padding0;
}
/* 天空布局 */
.sky {
  width100%;
  height600px;
  background: linear-gradient(rgb(196228253), #fff);
}
/* 第一朵云 */
.cloud1 {
  width100px;
  height25px;
  border-radius: 25px;
  positionrelative;
  right150px;
  top140px;
  background#ffffff;
  transform: scale(2.12.1);
  z-index9999;
  opacity: 0.9;
  animation: cloud1 14s linear 0s infinite;
}
 
@keyframes cloud1 {
  0% {
    right-100%;
  }
  100% {
    right100%;
  }
}
 
.cloud1:before {
  positionabsolute;
  width50px;
  height25px;
  border-radius: 25px;
  background#ffffff;
  content"";
  transform: rotate(60deg);
  left5px;
  top-2px;
}
.cloud1::after {
  positionabsolute;
  width60px;
  height60px;
  border-radius: 60px;
  background#ffffff;
  content"";
  left30px;
  top-25px;
}
 
/* 第二朵云 */
.cloud2 {
    width100px;
    height25px;
    border-radius: 25px;
    positionrelative;
    right150px;
    top45px;
    background#ffffff;
    transform: scale(1.91.9);
    z-index9999;
    opacity: 0.8;
    animation: cloud2 17s linear 0s infinite;
  }
   
  @keyframes cloud2 {
    0% {
      right-100%;
    }
    100% {
      right100%;
    }
  }
   
  .cloud2:before {
    positionabsolute;
    width50px;
    height25px;
    border-radius: 25px;
    background#ffffff;
    content"";
    transform: rotate(60deg);
    left5px;
    top-2px;
  }
  .cloud2::after {
    positionabsolute;
    width60px;
    height60px;
    border-radius: 60px;
    background#ffffff;
    content"";
    left30px;
    top-25px;
  }
 
/* 第三朵云 */
  .cloud3 {
    width100px;
    height25px;
    border-radius: 25px;
    positionrelative;
    right150px;
    top180px;
    background#ffffff;
    transform: scale(1.91.9);
    z-index9999;
    opacity: 0.7;
    animation: cloud3 16s linear 0s infinite;
  }
   
  @keyframes cloud3 {
    0% {
      right-100%;
    }
    100% {
      right100%;
    }
  }
   
  .cloud3:before {
    positionabsolute;
    width50px;
    height25px;
    border-radius: 25px;
    background#ffffff;
    content"";
    transform: rotate(60deg);
    left5px;
    top-2px;
  }
  .cloud3::after {
    positionabsolute;
    width60px;
    height60px;
    border-radius: 60px;
    background#ffffff;
    content"";
    left30px;
    top-25px;
  }
 
  /* 第四朵云 */
  .cloud4 {
    width100px;
    height25px;
    border-radius: 25px;
    positionrelative;
    right150px;
    top-5px;
    background#ffffff;
    transform: scale(1.81.8);
    z-index9999;
    opacity: 0.9;
    animation: cloud4 17s linear 0s infinite;
  }
   
  @keyframes cloud4 {
    0% {
      right-115%;
    }
    100% {
      right100%;
    }
  }
   
  .cloud4:before {
    positionabsolute;
    width50px;
    height25px;
    border-radius: 25px;
    background#ffffff;
    content"";
    transform: rotate(60deg);
    left5px;
    top-2px;
  }
  .cloud4::after {
    positionabsolute;
    width60px;
    height60px;
    border-radius: 60px;
    background#ffffff;
    content"";
    left30px;
    top-25px;
  }
 
/* 第五朵云 */
  .cloud5 {
    width100px;
    height25px;
    border-radius: 25px;
    positionrelative;
    right150px;
    top80px;
    background#ffffff;
    transform: scale(1.61.6);
    z-index9999;
    opacity: 0.6;
    animation: cloud5 20s linear 0s infinite;
  }
   
  @keyframes cloud5 {
    0% {
      right-115%;
    }
    100% {
      right100%;
    }
  }
   
  .cloud5:before {
    positionabsolute;
    width50px;
    height25px;
    border-radius: 25px;
    background#ffffff;
    content"";
    transform: rotate(60deg);
    left5px;
    top-2px;
  }
  .cloud5::after {
    positionabsolute;
    width60px;
    height60px;
    border-radius: 60px;
    background#ffffff;
    content"";
    left30px;
    top-25px;
  }
   
  /* 草地部分 */
.land {
  width100%;
  height400px;
  background: linear-gradient(#fffrgb(14819089));
  positionrelative;
}
 
/* 小兔子图像 */
.rabbit {
  /* transform: scale(0.2, 0.2);
  position: absolute;
  bottom: -440px;
  right: -300px; */
  width100px;
  height100px;
  border1px red soild;
  border-radius: 50px;
  backgroundred;
  positionabsolute;
  text-aligncenter;
  line-height100px;
  right200px;
  bottom50px;
}


正在回答

登陆购买课程后可参与讨论,去登陆

2回答

同学你好, “敲键盘侠”这位同学给的建议很棒哦, 可以将动画帧写成一个, 调整动画的时间和延迟时间, 简化代码书写

  1. 云朵的动画帧使用一个即可哦, 示例:

    http://img1.sycdn.imooc.com//climg/5d8c1ad4095c822e04520247.jpg

    http://img1.sycdn.imooc.com//climg/5d8c1af009a19b5407240411.jpg

    其他的云朵道理一样,修改动画的名称即可

  2. 水平方向出现了滚动条, 建议: 可以给body添加overflow:hidden;属性,超出隐藏

    http://img1.sycdn.imooc.com//climg/5d8c1b6e09f9555402790109.jpg

  3. 兔子可以引入图片

    http://img1.sycdn.imooc.com//climg/5d8c1b7d0978785308810126.jpg

    通过CSS设置样式, 可以给图片设置固定的宽度, 然后给外层设置绝对定位, 通过right和bottom属性设置兔子的位置

    http://img1.sycdn.imooc.com//climg/5d8c1ca609608f5905710721.jpg

    效果图:

    http://img1.sycdn.imooc.com//climg/5d8c1c1f0926c68b04160280.jpg

同学完成作业之后,可以提交作业哦,批作业的老师会针对同学的项目给出详细的指导建议, 以稳当的详细发给同学,便于同学查看哦

如果帮助到了你, 欢迎采纳!

祝学习愉快~~~


敲着敲着 2019-09-26 01:56:45

云朵代码长了点,可以每个云朵插入同一个animation-Name;调整延迟。这样简洁一些。http://img1.sycdn.imooc.com//climg/5d8baa080930867307840888.jpg

  • 兔子我用一个div把整个兔子包含,后期用transform:translate()调整位置,scale()t调整大小。
    2019-09-26 02:00:14
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师
插入代码