虽然效果实现了 但是感觉问题很多。请老师指导。小兔子位置我使用图块代替。不然您那边不显示兔子。
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 | * { margin : 0 ; padding : 0 ; } /* 天空布局 */ .sky { width : 100% ; height : 600px ; background : linear-gradient( rgb ( 196 , 228 , 253 ), #fff ); } /* 第一朵云 */ .cloud 1 { width : 100px ; height : 25px ; border-radius: 25px ; position : relative ; right : 150px ; top : 140px ; background : #ffffff ; transform: scale( 2.1 , 2.1 ); z-index : 9999 ; opacity: 0.9 ; animation: cloud 1 14 s linear 0 s infinite; } @keyframes cloud 1 { 0% { right : -100% ; } 100% { right : 100% ; } } .cloud 1: before { position : absolute ; width : 50px ; height : 25px ; border-radius: 25px ; background : #ffffff ; content : "" ; transform: rotate( 60 deg); left : 5px ; top : -2px ; } .cloud 1: :after { position : absolute ; width : 60px ; height : 60px ; border-radius: 60px ; background : #ffffff ; content : "" ; left : 30px ; top : -25px ; } /* 第二朵云 */ .cloud 2 { width : 100px ; height : 25px ; border-radius: 25px ; position : relative ; right : 150px ; top : 45px ; background : #ffffff ; transform: scale( 1.9 , 1.9 ); z-index : 9999 ; opacity: 0.8 ; animation: cloud 2 17 s linear 0 s infinite; } @keyframes cloud 2 { 0% { right : -100% ; } 100% { right : 100% ; } } .cloud 2: before { position : absolute ; width : 50px ; height : 25px ; border-radius: 25px ; background : #ffffff ; content : "" ; transform: rotate( 60 deg); left : 5px ; top : -2px ; } .cloud 2: :after { position : absolute ; width : 60px ; height : 60px ; border-radius: 60px ; background : #ffffff ; content : "" ; left : 30px ; top : -25px ; } /* 第三朵云 */ .cloud 3 { width : 100px ; height : 25px ; border-radius: 25px ; position : relative ; right : 150px ; top : 180px ; background : #ffffff ; transform: scale( 1.9 , 1.9 ); z-index : 9999 ; opacity: 0.7 ; animation: cloud 3 16 s linear 0 s infinite; } @keyframes cloud 3 { 0% { right : -100% ; } 100% { right : 100% ; } } .cloud 3: before { position : absolute ; width : 50px ; height : 25px ; border-radius: 25px ; background : #ffffff ; content : "" ; transform: rotate( 60 deg); left : 5px ; top : -2px ; } .cloud 3: :after { position : absolute ; width : 60px ; height : 60px ; border-radius: 60px ; background : #ffffff ; content : "" ; left : 30px ; top : -25px ; } /* 第四朵云 */ .cloud 4 { width : 100px ; height : 25px ; border-radius: 25px ; position : relative ; right : 150px ; top : -5px ; background : #ffffff ; transform: scale( 1.8 , 1.8 ); z-index : 9999 ; opacity: 0.9 ; animation: cloud 4 17 s linear 0 s infinite; } @keyframes cloud 4 { 0% { right : -115% ; } 100% { right : 100% ; } } .cloud 4: before { position : absolute ; width : 50px ; height : 25px ; border-radius: 25px ; background : #ffffff ; content : "" ; transform: rotate( 60 deg); left : 5px ; top : -2px ; } .cloud 4: :after { position : absolute ; width : 60px ; height : 60px ; border-radius: 60px ; background : #ffffff ; content : "" ; left : 30px ; top : -25px ; } /* 第五朵云 */ .cloud 5 { width : 100px ; height : 25px ; border-radius: 25px ; position : relative ; right : 150px ; top : 80px ; background : #ffffff ; transform: scale( 1.6 , 1.6 ); z-index : 9999 ; opacity: 0.6 ; animation: cloud 5 20 s linear 0 s infinite; } @keyframes cloud 5 { 0% { right : -115% ; } 100% { right : 100% ; } } .cloud 5: before { position : absolute ; width : 50px ; height : 25px ; border-radius: 25px ; background : #ffffff ; content : "" ; transform: rotate( 60 deg); left : 5px ; top : -2px ; } .cloud 5: :after { position : absolute ; width : 60px ; height : 60px ; border-radius: 60px ; background : #ffffff ; content : "" ; left : 30px ; top : -25px ; } /* 草地部分 */ .land { width : 100% ; height : 400px ; background : linear-gradient( #fff , rgb ( 148 , 190 , 89 )); position : relative ; } /* 小兔子图像 */ .rabbit { /* transform: scale(0.2, 0.2); position: absolute; bottom: -440px; right: -300px; */ width : 100px ; height : 100px ; border : 1px red soild; border-radius: 50px ; background : red ; position : absolute ; text-align : center ; line-height : 100px ; right : 200px ; bottom : 50px ; } |
6
收起
正在回答
2回答
同学你好, “敲键盘侠”这位同学给的建议很棒哦, 可以将动画帧写成一个, 调整动画的时间和延迟时间, 简化代码书写
云朵的动画帧使用一个即可哦, 示例:
其他的云朵道理一样,修改动画的名称即可
水平方向出现了滚动条, 建议: 可以给body添加overflow:hidden;属性,超出隐藏
兔子可以引入图片
通过CSS设置样式, 可以给图片设置固定的宽度, 然后给外层设置绝对定位, 通过right和bottom属性设置兔子的位置
效果图:
同学完成作业之后,可以提交作业哦,批作业的老师会针对同学的项目给出详细的指导建议, 以稳当的详细发给同学,便于同学查看哦
如果帮助到了你, 欢迎采纳!
祝学习愉快~~~
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧