css布局实现两只带阴影的鱼游动动画效果代码
代码语言:html
所属分类:动画
代码描述:css布局实现两只带阴影的鱼游动动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { --coilSize: 14px; --delayCount: 40ms; --scaleMe: 1; --scaleFlip: 1; --posFlip: 0; } body, .seaLevel { font-family: "Open Sans", sans-serif; background-color: lightblue; overflow: hidden; } .fish { position: absolute; top: -35%; left: 0; width: 100%; height: 100%; filter: drop-shadow( calc(var(--coilSize) * 4) calc(var(--coilSize) / 3) 5px rgba(0, 0, 0, 0.3) ); } .fish .koiCoil { position: absolute; width: var(--coilSize); height: var(--coilSize); background-color: orangered; border-radius: 50%; top: 50%; left: 50%; margin-left: calc(var(--coilSize) / -2); margin-top: calc(var(--coilSize) / -2); transform: scale(var(--scaleMe), var(--scaleMe)); filter: contrast(200%); offset-path: path( "M11.7692 229.5C14.552 200.052 7.51901 171.858 -42.8757 170.644C-105.869 169.128 -131.294 76.612 -101.695 51.5872C-72.0955 26.5625 -24.6607 -50.7867 70.5883 51.5872C165.837 153.961 27.7073 131.211 33.0199 183.157C38.3326 235.102 90.3211 195.669 139.274 223.727C188.226 251.785 207.959 299.56 139.274 316.243C70.5883 332.926 41.3685 398.9 81.9726 419.754C122.577 440.608 222 478.524 222 419.754C222 372.738 222 242.432 222 183.157C219.091 129.948 175.78 30.8091 25.8099 59.9288C-161.652 96.3284 -30.3529 119.837 25.8099 141.07C81.9726 162.303 171.529 204.769 126.751 260.506C81.9726 316.243 101.326 362.501 139.274 373.496C177.222 384.492 170.012 464.495 70.5883 462.979C-28.835 461.462 -42.8757 393.015 -42.8757 373.496C-42.8757 238.288 11.7692 293 11.7692 240.506C11.7692 208.05 11.7692 237.336 11.7692 229.5Z" ); -webkit-animation: fishAnim 20000ms linear infinite; animation: fishAnim 20000ms linear infinite; box-shadow: calc(var(--coilSize) / -2) calc(var(--coilSize) / -10) 0 white inset; } .fish:nth-of-type(2) { transform-origin: top center; transform: scale(-1, 1); filter: drop-shadow( calc(var(--coilSize) * -4) calc(var(--coilSize) / 3) 5px rgba(0, 0, 0, 0.3) ); } .fish:nth-of-type(2) .koiCoil { background-color: white; box-shadow: calc(var(--coilSize) / -2) calc(var(--coilSize) / -10) 0 orangered inset; } .fish .koiCoil:nth-of-type(15), .fish .koiCoil:nth-of-type(14) { background-color: orangered; } .fish:nth-of-type(2) .koiCoil:nth-of-type(15), .fish:nth-of-type(2) .koiCoil:nth-of-type(14) { background-color: white; } .fish .koiCoil:nth-of-type(15)::after { content: ":"; position: absolute; color: black; font-weight: 800; text-align: center; line-height: 60%; font-size: calc(var(--coilSize) * 1.2); } .fish .koiCoil:nth-of-type(1)::before { content: ""; position: absolute; width: 100%; height: 50%; top: 25%; left: -100%; border-radius: var(--coilSize); background-color: white; /*box-shadow: calc(var(--coilSize) / -10) calc(var(--coilSize) / -4) calc(var(--coilSize) / 3) rgba(0,0,0,.3) inset;*/ transform-origin: center right; -webkit-animation: backFlip 200ms ease-in-out alternate infinite; animation: backFlip 200ms ease-in-out alternate infinite; } .fish .koiCoil:nth-of-type(14) { --scaleMe: 1.2; -webkit-animation-delay: calc(var(--delayCount) * 1); animation-delay: calc(var(--delayCount) * 1); } .fish .koiCoil:nth-of-type(13) { --scaleMe: 1.35; -webkit-animation-delay: calc(var(--delayCount) * 2); animation-delay: calc(var(--delayCount) * 2); } .fish .koiCoil:nth-of-type(12) { --scaleMe: 1.55; -webkit-animation-delay: calc(var(--delayCount) * 3); animation-delay: calc(var(--delayCount) * 3); } .fish .koiCoil:nth-of-type(11) { --scaleMe: 1.75; -webkit-animation-delay: calc(var(--delayCount) * 4); animation-delay: calc(var(--delayCount) * 4); } .fish .koiCoil:nth-of-type(10) { --scaleMe: 1.9; -webkit-animation-delay: calc(var(--delayCount) * 5); animation-delay: calc(var(--delayCount) * 5); } .fish .koiCoil:nth-of-type(9) { --scaleMe: 2; -webkit-animation-delay: calc(var(--delayCount) * 6); animation-delay: calc(var(--delayCount) * 6); } .fish .koiCoil:nth-of-type(8) { --scaleMe: 2; -webkit-animation-delay: calc(var(--delayCount) * 7); animation-delay: calc(var(--delayCount) * 7); } .fish .koiCoil:nth-of-type(7) { --sca.........完整代码请登录后点击上方下载按钮下载查看
网友评论0