Advertisement
NGaming

Meshy Dog CSS

Nov 28th, 2016
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.06 KB | None | 0 0
  1. $dog-width: 100px;
  2. $interval: 200ms;
  3. $color-gray: #EAEBEC;
  4. $easing: ease-in-out;
  5.  
  6. .ball {
  7. width: 32px;
  8. height: 32px;
  9. border-radius: 50%;
  10. margin-top: 4rem;
  11. z-index: 0;
  12.  
  13. &:after {
  14. content: '';
  15. position: absolute;
  16. display: block;
  17. top: 0;
  18. left: 0;
  19. height: 100%;
  20. width: 100%;
  21. border-radius: 50%;
  22. box-shadow: inset 0 -8px 0 0 rgba(black, 0.2);
  23. background: #6E64F0;
  24. z-index: 1;
  25. }
  26.  
  27. &:focus {
  28. outline: none;
  29.  
  30. &:after {
  31. animation: bounce $interval * 2 infinite alternate;
  32. }
  33.  
  34. @keyframes bounce {
  35. from {
  36. transform: scale(2);
  37. animation-timing-function: ease-in;
  38. }
  39. to {
  40. transform: scale(0.8);
  41. animation-timing-function: cubic-bezier(0, 0, 0, 1);
  42. }
  43. }
  44.  
  45. @keyframes bounce-shadow {
  46. from {
  47. transform: scale(2.5, 2.6) translateY(-50%);
  48. animation-timing-function: ease-in;
  49. }
  50. to {
  51. transform: scale(0.5) translateY(0);
  52. animation-timing-function: cubic-bezier(0, 0, 0, 1);
  53. }
  54. }
  55.  
  56. &:before {
  57. content: '';
  58. position: absolute;
  59. display: block;
  60. top: 0;
  61. left: 0;
  62. width: 100%;
  63. height: 100%;
  64. border-radius: 50%;
  65. background: rgba(black, 0.05);
  66. animation: bounce-shadow $interval * 2 infinite alternate;
  67. z-index: -10;
  68. }
  69. }
  70. }
  71.  
  72. .dog {
  73. width: $dog-width;
  74. height: $dog-width;
  75. z-index: 1;
  76.  
  77. &:before {
  78. content: '';
  79. display: block;
  80. position: absolute;
  81. width: 100%;
  82. height: 100%;
  83. border-radius: 50%;
  84. background: rgba(black, 0.03);
  85. transform: translateY(-30%) scale(1.5);
  86. }
  87.  
  88. * {
  89. position: absolute;
  90. }
  91. }
  92.  
  93. .dog-body {
  94. top: -50%;
  95. animation: dog-body $interval $easing infinite alternate;
  96.  
  97. &:before {
  98. content: '';
  99. position: absolute;
  100. bottom: 90%;
  101. right: 50%;
  102. width: 90%;
  103. height: 90%;
  104. border-top-left-radius: 100%;
  105. border-bottom-left-radius: 10%;
  106. border-top-right-radius: 10%;
  107. background: rgba(white, 0.4);
  108. // transform: rotate(45deg);
  109. transform-origin: right bottom;
  110. animation: dog-tail-blur $interval $interval / 6 $easing infinite alternate both;
  111.  
  112. @keyframes dog-tail-blur {
  113. from {
  114. transform: rotate(0);
  115. opacity: 0;
  116. }
  117. 50% {
  118. // transform: rotate(45deg);
  119. opacity: 1;
  120. }
  121. to {
  122. transform: rotate(90deg);
  123. opacity: 0;
  124. }
  125. }
  126. }
  127.  
  128. @keyframes dog-body {
  129. from {
  130. transform: translateX(-10%);
  131. }
  132. to {
  133. transform: translateX(10%);
  134. }
  135. }
  136. }
  137.  
  138. .dog-head {
  139. animation: dog-head $interval * 9 cubic-bezier(0.11, 0.79, 0, 0.99) infinite;
  140.  
  141. @keyframes dog-head {
  142. from, to {
  143. transform: rotate(45deg);
  144. }
  145. 33.3% {
  146. transform: rotate(-45deg);
  147. }
  148. 66.6% {
  149. transform: rotate(0);
  150. }
  151. }
  152. }
  153.  
  154. .dog-torso {
  155. top: -20%;
  156. animation: dog-torso $interval $easing infinite alternate-reverse;
  157.  
  158. @keyframes dog-torso {
  159. from {
  160. transform: translateX(-5%);
  161. }
  162. to {
  163. transform: translateX(5%);
  164. }
  165. }
  166. }
  167.  
  168. .dog-eyes {
  169. width: 60%;
  170. top: 55%;
  171. left: 20%;
  172. z-index: 1;
  173.  
  174. &:before {
  175. content: '';
  176. display: block;
  177. height: 40px;
  178. width: 40px;
  179. border-radius: 40px;
  180. position: absolute;
  181. background: orange;
  182. top: -10px;
  183. left: -10px;
  184. z-index: 0;
  185. border: 4px solid white;
  186. border-left-width: 0;
  187. border-bottom-width: 0;
  188. border-top-width: 0;
  189. transform: rotate(-45deg);
  190. }
  191. }
  192.  
  193. .dog-eye {
  194. width: 10px;
  195. height: 10px;
  196. border-radius: 50%;
  197. background: #000;
  198. z-index: 1;
  199. animation: dog-eye $interval * 9 infinite;
  200.  
  201. @keyframes dog-eye {
  202. from, to {
  203. animation-timing-function: step-end;
  204. opacity: 1;
  205. }
  206. 50%, 55% {
  207. animation-timing-function: step-start;
  208. opacity: 0;
  209. }
  210. }
  211.  
  212. &:first-child {
  213. left: 0;
  214. }
  215. &:last-child {
  216. right: 0;
  217. }
  218. }
  219.  
  220. .dog-muzzle {
  221. width: 60%;
  222. left: 20%;
  223. height: 50%;
  224. border-bottom-left-radius: 100%;
  225. border-bottom-right-radius: 100%;
  226. background: white;
  227. bottom: -15%;
  228.  
  229. &:before, &:after {
  230. content: '';
  231. display: block;
  232. position: absolute;
  233. }
  234.  
  235. &:before {
  236. width: 6px;
  237. height: 20px;
  238. bottom: 0;
  239. left: calc(50% - 3px);
  240. background: $color-gray;
  241. }
  242.  
  243. &:after {
  244. background: black;
  245. width: 20px;
  246. height: 15px;
  247. bottom: 12px;
  248. left: calc(50% - 10px);
  249. border-bottom-left-radius: 60% 60%;
  250. border-bottom-right-radius: 60% 60%;
  251. border-top-left-radius: 50% 40%;
  252. border-top-right-radius: 50% 40%;
  253. }
  254. }
  255.  
  256. @function p($v) {
  257. @return percentage($v);
  258. }
  259.  
  260. .dog-tongue {
  261. width: 40px;
  262. height: 100%;
  263. left: calc(50% - 20px);
  264. z-index: -1;
  265. transform-origin: center top;
  266. animation: dog-tongue $interval * 9 -50ms ease-in-out infinite;
  267.  
  268. @keyframes dog-tongue {
  269. from, to {
  270. transform: rotate(0);
  271. }
  272. #{p(1/6)} {
  273. transform: rotate(30deg);
  274. }
  275. #{p(2/6)}, #{p(4/6)} {
  276. transform: rotate(0);
  277. }
  278. #{p(3/6)}, #{p(5/6)} {
  279. transform: rotate(-20deg);
  280. }
  281. }
  282.  
  283. &:before {
  284. content: '';
  285. position: absolute;
  286. display: block;
  287. width: 100%;
  288. height: 100%;
  289. border-radius: 40px;
  290.  
  291. background: #FD3163;
  292. animation: dog-tongue-inner $interval / 2 $easing infinite alternate;
  293.  
  294. @keyframes dog-tongue-inner {
  295. from {
  296. transform: translateY(5%);
  297. }
  298. to {
  299. transform: translateY(22%);
  300. }
  301. }
  302. }
  303. }
  304.  
  305. .dog-ears {
  306. width: 40%;
  307. top: 25%;
  308. left: 30%;
  309. animation: dog-ears $interval * 9 $interval / 2 ease infinite;
  310.  
  311. @keyframes dog-ears {
  312. 42.3%, 71.6% {
  313. transform: rotate(-5deg);
  314. }
  315. 50.3%, 79.6% {
  316. transform: rotate(5deg);
  317. }
  318. 5% {
  319. transform: rotate(5deg);
  320. }
  321. 12% {
  322. transform: rotate(-5%);
  323. }
  324. from, 33.3%, 66%, to {
  325. transform: rotate(0);
  326. }
  327. }
  328. }
  329.  
  330. .dog-ear {
  331. bottom: -10px;
  332. height: 50px;
  333. width: 50px;
  334. background: $color-gray;
  335. animation-duration: $interval * 2;
  336. animation-direction: alternate;
  337. animation-timing-function: ease-in-out;
  338. animation-fill-mode: both;
  339. animation-iteration-count: infinite;
  340.  
  341. &:first-child {
  342. border-bottom-left-radius: 80%;
  343. border-top-right-radius: 80%;
  344. right: 100%;
  345. box-shadow: inset -15px 15px 0 1px white;
  346. transform-origin: right bottom;
  347. transform: rotate(10deg);
  348. }
  349.  
  350. &:last-child {
  351. border-top-left-radius: 80%;
  352. border-bottom-right-radius: 80%;
  353. left: 100%;
  354. box-shadow: inset 15px 15px 0 0 white;
  355. transform-origin: left bottom;
  356. transform: rotate(-10deg);
  357. }
  358. }
  359.  
  360. .dog-tail {
  361. $tail-width: 22px;
  362. width: $tail-width;
  363. height: $tail-width * 1.1;
  364. background: white;
  365. bottom: 40%;
  366. border-radius: $tail-width / 2;
  367. left: calc(50% - #{$tail-width / 2});
  368. transform-origin: center bottom;
  369.  
  370. .dog-tail {
  371. animation: dog-tail-segment $interval $easing infinite alternate;
  372.  
  373. @keyframes dog-tail-segment {
  374. from {
  375. transform: rotate(-10deg);
  376. }
  377. to {
  378. transform: rotate(10deg);
  379. }
  380. }
  381. }
  382. }
  383.  
  384. .dog-body > .dog-tail {
  385. bottom: 90%;
  386. animation: dog-tail $interval $easing infinite alternate;
  387.  
  388. @keyframes dog-tail {
  389. from {
  390. transform: rotate(-45deg);
  391. }
  392. to {
  393. transform: rotate(45deg);
  394. }
  395. }
  396. }
  397.  
  398. .dog-body,
  399. .dog-torso,
  400. .dog-head {
  401. border-radius: 50%;
  402. background: white;
  403. position: absolute;
  404. height: 100%;
  405. width: 100%;
  406. }
  407.  
  408. .dog-body, .dog-torso {
  409. box-shadow: inset 0 -15px 0 0 $color-gray;
  410. }
  411.  
  412. body {
  413. display: flex;
  414. flex-direction: column;
  415. justify-content: center;
  416. align-items: center;
  417. }
  418.  
  419. html, body {
  420. background: #FFE16E;
  421. width: 100%;
  422. height: 100%;
  423. margin: 0;
  424. padding: 0;
  425. }
  426.  
  427. *, *:before, *:after {
  428. box-sizing: border-box;
  429. position: relative;
  430. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement