Интересная анимация магазина с помощью CSS
Продолжаем рассматривать различные анимации которые меня заинтересовали, в данном посте мы посмотрим вариант реализации интересной анимации для магазина. Такое решение отлично подойдет для заглушки сайта или для организации фона. Основная идея состоит в том, что элементы в анимации появляются постепенно с плавной анимацией, то есть магазин разворачивается постепенно при этом нет никаких тормозов и подвисаний, в связи использовании только правил css и полного отсутствия изображений, что значительно упрощает работу с анимацией и придает ей гибкости.
При перезагрузке страницы анимация будет повторяться. И так, давайте приступим.
Шаг 1. 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 |
<div class="cloud cloud1"> <ul> <li></li> <li></li> <li></li> <li></li> </ul> </div> <div class="cloud cloud2"> <ul> <li></li> <li></li> <li></li> <li></li> </ul> </div> <div class="sign">ОТКРЫТО</div> <div class="store_roof"> <ul> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> </div> <div class="store_roof_opening"></div> <div class="store_window"></div> <div class="store_door"></div> <div class="store_sign">МОЙ МАГАЗИН</div> <div class="store_frame_shadow"></div> <div class="store_frame"></div> <div class="store_inner_wall"></div> <div class="store_wall"></div> <div class="store_floor"></div> <div class="kerb"><div class="left"></div><div class="right"></div></div> <div class="road"></div> <div class="floor"></div> |
С разметкой трудностей возникнуть не должно, теперь давайте перейдем к следующему шагу.
Шаг 2. CSS
Для начала нам необходимо определить несколько общих правил:
1 2 3 4 5 |
body{ margin: 0; padding: 0; background: #A0EDF7; } |
Далее установим параметры для тучек и их небольшой анимации:
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 |
.cloud1{ width: 170px; height: 39px; position: absolute; left: 100px; top: 130px; } .cloud2{ width: 170px; height: 39px; position: absolute; left: 600px; top: 230px; } .cloud ul{ list-style: none; margin: 0; padding: 0; } .cloud ul li{ background: #fff; float: left; border-radius: 360px; border-right: 14px solid #F7E7EB; margin-left: -20px; opacity: 0; -webkit-transform: rotate(65deg); -webkit-animation: cloud 0.3s 1.4s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } .cloud ul li:first-child{ width: 46px; height: 60px; margin-left: 30px; margin-top: -20px; } .cloud ul li:nth-child(2){ width: 26px; height: 40px; margin-left: -82px; } .cloud ul li:nth-child(3){ width: 56px; height: 70px; margin-left: -20px; margin-top: -30px; } .cloud ul li:nth-child(4){ width: 26px; height: 40px; margin-left: -20px; } |
Затем, мы создаем подвал, он будет состоять из толстой серой линии которая будет создавать эффект земли, и полоски, которая будет разделять магазин и землю, для них тоже не забываем анимацию:
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 |
</p> .floor{ position: absolute; width: 0px; height: 0px; background: #868994; bottom: 40px; left: 50%; z-index: 5; -webkit-animation: floor 0.3s 0.3s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } .road{ position: absolute; width: 0px; height: 0px; background: #636272; bottom: 40px; left: 50%; z-index: 5; -webkit-animation: road 0.3s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } .kerb{ position: absolute; width: 0px; height: 0px; background: #B2B2B2; bottom: 45px; left: 50%; z-index: 5; -webkit-animation: kerb 0.3s 0.3s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } .kerb .right{ position: absolute; width: 0px; height: 12px; background: #969798; bottom: 0; right: 0; -webkit-animation: kerb-right 0.2s 0.4s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } .kerb .left{ position: absolute; width: 0; height: 12px; background: #C4D1CF; bottom: 0; left: 0; -webkit-animation: kerb-left 0.4s 0.6s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } |
Затем сам магазин:
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 |
.store_floor{ position: absolute; width: 0; height: 60px; background: #A24549; bottom: 0; left: 0; z-index: 5; box-shadow: 0 -5px 0 #BE6151; -webkit-animation: store_floor 0.3s 0.7s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } .store_wall{ position: absolute; width: 0; height: 60px; background: #FFEFD3; bottom: 0; left: 0; -webkit-animation: store_wall 0.4s 0.9s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } .store_inner_wall{ position: absolute; width: 0; height: 60px; background: #CF595D; bottom: 0; left: 0; z-index: 4; box-shadow: inset 3px 0 0 rgba(0,0,0,0.1), inset 3px 5px 0 rgba(0,0,0,0.2); -webkit-animation: store_inner_wall 0.4s 0.9s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } .store_frame{ position: absolute; width: 400px; height: 30px; background: #FFEFD3; bottom: 330px; left: calc(50% - 150px); z-index: 5; opacity: 0; -webkit-animation: store_frame 0.2s 1.1s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } .store_frame_shadow{ position: absolute; width: 380px; height: 36px; background: rgba(0,0,0,0.2); bottom: 330px; left: calc(50% - 140px); z-index: 5; opacity: 0; -webkit-animation: store_frame_shadow 0.3s 1.0s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } .store_sign{ position: absolute; width: 140px; height: 0px; background: #FFFF8A; bottom: 345px; left: calc(50% - 30px); box-shadow: 0 2px 0 rgba(0,0,0,0.2); z-index: 6; opacity: 0; -webkit-animation: store_sign 0.2s 1.3s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; color: rgba(0,0,0,0.4); font-family: Courier; font-size: 20px; text-align: center; padding: 10px; } .store_door{ position: absolute; width: 75px; height: 0px; background: rgb(158,207,215); /* Old browsers */ border: 10px solid #FFFFF3; bottom: 57px; left: calc(50% + 95px); z-index: 6; opacity: 0; -webkit-animation: store_door 0.2s 1.3s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; box-shadow: inset 2px 2px 0 rgba(0,0,0,0.2); padding: 10px; } .store_door:after{ content: ''; position: absolute; top: 46%; left: -5px; width: 110px; height: 20px; background: #FFEFD3; box-shadow: 0 2px 0 rgba(0,0,0,0.2); border-radius: 2px; } .store_door:before{ content: ''; position: absolute; top: 92px; z-index: 10; left: 2px; width: 30px; height: 3px; background: rgba(0,0,0,0.2); border-radius: 2px; } .store_window{ position: absolute; width: 160px; height: 0px; border: 3px solid #FFFFF3; bottom: 116px; left: calc(50% - 110px); z-index: 6; opacity: 0; -webkit-animation: store_window 0.2s 1.3s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; box-shadow: inset 2px 2px 0 rgba(0,0,0,0.2); padding: 10px; } .store_roof_opening{ position: absolute; width: 216px; height: 9px; background: #FFEFD3; bottom: 280px; left: calc(50% - 120px); z-index: 5; opacity: 0; box-shadow: 0 2px 0 rgba(0,0,0,0.2); -webkit-animation: store_roof_opening 0.2s 1.3s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } .store_roof{ position: absolute; bottom: 100px; left: calc(50% - 115px); height: 200px; width: 340px; z-index: 12; } .store_roof ul{ list-style: none; float: left; margin: 0; padding: 0; } .store_roof ul li{ width: 35px; height: 100px; opacity: 0; float: left; background: #EB6159; -webkit-transform: skew(-25deg) rotateX(45deg); -webkit-animation: store_roof 0.2s 1.5s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } .store_roof ul li:nth-child(2n){ background: #FFFBF1; } .store_roof ul li:nth-child(2n):after{ background: #F7F7F7; } .store_roof ul li:before{ content: ''; position: absolute; bottom: 0; left: 0; height: 10px; width: 100%; background: rgba(255,255,255,0.1); } .store_roof ul li:after{ content: ''; position: absolute; top: 93px; left: 5px; width: 35px; height: 45px; box-shadow: 0 7px 0 rgba(0,0,0,0.2); border-bottom-left-radius: 30px; border-bottom-right-radius: 30px; background: #DF5551; -webkit-transform: skew(18deg) rotateX(-45deg); } .sign{ position: absolute; bottom: 180px; left: calc(50% + 120px); width: 60px; border-radius: 2px; z-index: 12; height: 13px; background: #FFFFF3; text-align: center; color: #99AA61; font-family: Arial; font-size: 11px; padding: 4px; opacity: 0; -webkit-animation: sign 0.7s 1.8s linear; /* Safari 4+ */ -webkit-animation-fill-mode: forwards; } .sign:after{ content: ''; width: 1px; height: 35px; background: #aaa; position: absolute; top: -30px; left: 21px; -webkit-transform: rotate(45deg); } .sign:before{ content: ''; width: 1px; height: 35px; background: #aaa; position: absolute; top: -30px; right: 21px; -webkit-transform: rotate(-45deg); } |
Вот и все. Готово!
Материал взят из зарубежного источника. И представлен исключительно в ознакомительных целях.
Читайте также:
Опубликовал Cooper 31.08.2013 в 15:23, в категории CSS. Вы можете следить за комментариями через RSS 2.0. Вы можете перейти в конец записи и оставить комментарий. Пинги запрещены. |