css布局实现忍者扔飞刀交互效果
代码语言:html
所属分类:动画
代码描述:css布局实现忍者扔飞刀交互效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link href="https://fonts.googleapis.com/css?family=Titillium+Web:200,200i,300,300i,400,400i,600,600i,700,700i,900&display=swap" rel="stylesheet"> <style> @charset "UTF-8"; :root { --ninjaBlack: #000; --ninjaBlack2: #010101; --ninjaGray: #888; --ninjaGray2: #eee; --ninjaSkin: #f1c27d; --ninjaSkin2: #ae8953; --ninjaBorder: #000; --ninjaBorderWidth: 2px; --animationDuration: 3s; --animationDelay: 0.5s; --animationCount: 1; --animationTiming: cubic-bezier(0.5, 0.1, 1, 0.8); --animationTiming: ease-out; } div { position: relative; } *::after, *::before { content: ""; position: absolute; display: block; } .ninja { -webkit-animation: kataMain var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: kataMain var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); min-width: 400px; height: 330px; display: -webkit-box; display: flex; -webkit-box-pack: center; justify-content: center; -webkit-transform-origin: bottom center; transform-origin: bottom center; -webkit-transition: 0.2s; transition: 0.2s; top: 0; cursor: pointer; } .ninja:hover .armBottom.arm2Bottom { -webkit-transform: rotate(145deg); transform: rotate(145deg); -webkit-transition: 0.2s; transition: 0.2s; } .ninja:hover .armBottom.arm1Bottom { -webkit-transform: rotate(-120deg); transform: rotate(-120deg); -webkit-transition: 0.2s; transition: 0.2s; } .ninja:hover .eye.eyeRight::after { top: -12px; } .ninja:hover .noggin { -webkit-transform: rotate(-10deg); transform: rotate(-10deg); } .ninja:hover .headBandWrap { top: -2em; right: 1em; -webkit-transform: rotate(-10deg) scaley(0.95); transform: rotate(-10deg) scaley(0.95); } .noggin { -webkit-animation: kata var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: kata var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); background: var(--ninjaBlack); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; border: var(--ninjaBorderWidth) solid var(--ninjaBorder); width: 9em; height: 8em; top: 0; display: -webkit-box; display: flex; -webkit-box-pack: center; justify-content: center; overflow: hidden; -webkit-transition: 0.2s; transition: 0.2s; } .noggin::before { content: "ninja"; color: var(--ninjaBlack); font-weight: 900; font-size: 0.9em; top: 2.1em; opacity: 1; z-index: 1; } .noggin:after { content: ""; position: absolute; top: 2.9em; display: block; width: 10em; height: 3em; border-radius: 50%; box-shadow: 0px -20px 0 0 var(--ninjaGray2); } .eyeHole { position: absolute; z-index: 0; display: -webkit-box; display: flex; justify-content: space-around; -webkit-box-align: center; align-items: center; padding: 15px 15px 0; width: 7em; height: 3em; background: var(--ninjaSkin); border-radius: 100px / 50px; bottom: 20px; border: var(--ninjaBorderWidth) solid var(--ninjaBorder); overflow: hidden; } .eyeHole::after { content: ""; display: block; position: absolute; top: 8px; width: 11em; height: 3em; border-radius: 50%; box-shadow: 0px -10px 0 0 var(--ninjaSkin2); } .eyeHole .eyeWrap { -webkit-animation: eyes var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: eyes var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); display: -webkit-box; display: flex; justify-content: space-around; width: 7em; } .eyeHole .eye { width: 20px; height: 20px; background: var(--ninjaBlack); border-radius: 50%; box-shadow: -4px -3px 0 0 var(--ninjaSkin2); -webkit-transition: 0.2s; transition: 0.2s; } .eyeHole .eye::before { content: ""; display: block; position: absolute; width: 8px; height: 8px; right: 2px; top: 2px; border-radius: 50%; background: #fff; } .eyeHole .eye::after { content: ""; display: block; position: absolute; width: 25px; height: 5px; background: var(--ninjaBlack); border-radius: 0 100%; -webkit-transition: 0.2s; transition: 0.2s; } .eyeHole .eye.eyeLeft { -webkit-animation: kataLeftEye 15s 7s ease-in-out infinite; animation: kataLeftEye 15s 7s ease-in-out infinite; -webkit-transform-origin: center; transform-origin: center; } .eyeHole .eye.eyeLeft::before { -webkit-animation: kataLeftEye2 15s 7s ease-in-out infinite; animation: kataLeftEye2 15s 7s ease-in-out infinite; } .eyeHole .eye.eyeLeft::after { top: -8px; right: 0; -webkit-transform: rotate(10deg); transform: rotate(10deg); -webkit-transition: 0.2s; transition: 0.2s; } .eyeHole .eye.eyeRight::after { -webkit-animation: kataEyebrow var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: kataEyebrow var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); top: -7px; -webkit-transform: rotate(-25deg); transform: rotate(-25deg); } .headBandWrap { -webkit-animation: kataBand var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: kataBand var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); -webkit-transition: 0.2s; transition: 0.2s; position: absolute; top: 0; right: 0em; -webkit-transform-origin: bottom left; transform-origin: bottom left; } .headBandWrap .headBand { position: absolute; z-index: -1; height: 2em; background: var(--ninjaGray2); border-radius: 0 100%; -webkit-transform-origin: 0 0; transform-origin: 0 0; border: var(--ninjaBorderWidth) solid var(--ninjaBorder); box-shadow: inset 0px -5px 0 0 var(--ninjaGray); } .headBandWrap .headBand.headBand1 { width: 5em; top: 3.9em; right: 6em; -webkit-transform: rotate(-50deg); transform: rotate(-40deg); } .headBandWrap .headBand.headBand2 { width: 3em; top: 3em; right: 6em; -webkit-transform: rotate(0deg); transform: rotate(0deg); } .torso { -webkit-animation: kata2 var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: kata2 var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); background: var(--ninjaBlack); position: absolute; top: 6em; width: 6.5em; height: 6em; -webkit-transform-origin: bottom center; transform-origin: bottom center; } .arms { top: 0.5em; } .arms > *, .arms > * > * { position: absolute; } .arms .arm1 { -webkit-animation: arm1Kata var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: arm1Kata var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); left: 0; -webkit-transform: rotate(35deg); transform: rotate(35deg); -webkit-transform-origin: top left; transform-origin: top left; } .arms .arm2 { -webkit-animation: arm2Kata var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: arm2Kata var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); top: 2em; right: 1.8em; -webkit-transform: rotate(-50deg); transform: rotate(-50deg); -webkit-transform-origin: top right; transform-origin: top right; } .arms .armTop { width: 2.5em; height: 5.5em; background: var(--ninjaBlack); border-radius: 1em; } .arms .armBottom, .arms .armBottomSleeve { position: absolute; width: 2.4em; top: 4.5em; height: 4em; } .arms .armBottom.arm1Bottom, .arms .armBottomSleeve.arm1Bottom { -webkit-animation: arm1bottomKata var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: arm1bottomKata var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); -webkit-transform-origin: top center; transform-origin: top center; -webkit-transform: rotate(-130deg); transform: rotate(-130deg); -webkit-transition: 0.2s; transition: 0.2s; } .arms .armBottom.arm2Bottom, .arms .armBottomSleeve.arm2Bottom { -webkit-animation: arm2bottomKata var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: arm2bottomKata var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); -webkit-transform-origin: top center; transform-origin: top center; -webkit-transform: rotate(140deg); transform: rotate(140deg); -webkit-transition: 0.2s; transition: 0.2s; } .arms .armBottom .hand, .arms .armBottomSleeve .hand { position: absolute; z-index: -1; width: 1.5em; height: 2em; background: var(--ninjaSkin); border: var(--ninjaBorderWidth) solid var(--ninjaBorder); box-shadow: inset 5px 0px 0 var(--ninjaSkin2); } .arms .armBottom .hand.hand1, .arms .armBottomSleeve .hand.hand1 { top: 3.6em; right: 0.4em; -webkit-transform: rotate(30deg); transform: rotate(-2deg); border-radius: 72% 28% 95% 25% / 46% 29% 71% 54%; } .arms .armBottom .hand.hand2, .arms .armBottomSleeve .hand.hand2 { top: 3.5em; right: 0.7em; -webkit-transform: rotate(-90deg); transform: rotate(-150deg); border-radius: 72% 18% 0% 0% / 81% 49% 14% 7%; } .arms .armBottom .armBottomSleeve, .arms .armBottomSleeve .armBottomSleeve { top: 0; background: var(--ninjaBlack2); border-top-left-radius: 1em; border-top-right-radius: 1em; } .pants { -webkit-animation: kata3 var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: kata3 var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); position: absolute; width: 6.5em; height: 2em; top: 12em; background: var(--ninjaBlack); -webkit-transform-origin: bottom center; transform-origin: bottom center; } .pants::after { content: ""; position: absolute; top: 2.1em; left: 2.6em; display: block; width: 1.3em; height: 3em; border-radius: 50%; box-shadow: 0px -20px 0 0 var(--ninjaBlack); } .pants .leg1 { -webkit-animation: kataLeg1 var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: kataLeg1 var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); position: absolute; left: 1px; -webkit-transform: rotate(10deg); transform: rotate(10deg); -webkit-transform-origin: top left; transform-origin: top left; } .pants .leg2 { -webkit-animation: kataLeg2 var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: kataLeg2 var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); position: absolute; top: 0; right: 1px; -webkit-transform: rotate(-10deg); transform: rotate(-10deg); -webkit-transform-origin: top right; transform-origin: top right; } .pants .legTop { width: 3.2em; height: 3.5em; background: var(--ninjaBlack); border-radius: 1em; } .pants .legBottom, .pants .legBottomSleeve { position: absolute; width: 3.2em; top: 2.5em; height: 3.5em; } .pants .legBottom.leg1Bottom, .pants .legBottomSleeve.leg1Bottom { -webkit-transform-origin: top center; transform-origin: top center; -webkit-transform: rotate(0deg); transform: rotate(0deg); } .pants .legBottom.leg2Bottom, .pants .legBottomSleeve.leg2Bottom { -webkit-animation: kataLeg2bottom var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: kataLeg2bottom var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); -webkit-transform-origin: top left; transform-origin: top left; top: 2.5em; right: 0.05em; -webkit-transform: rotate(0deg); transform: rotate(0deg); } .pants .legBottom .feet, .pants .legBottomSleeve .feet { position: absolute; z-index: -1; width: 3.5em; height: 2em; background: var(--ninjaBlack); } .pants .legBottom .feet.foot1, .pants .legBottomSleeve .feet.foot1 { -webkit-animation: kataFoot1 var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); animation: kataFoot1 var(--animationDuration) var(--animationDelay) var(--animationTiming) var(--animationCount); top: 3.1em; right: 0.1em; -webkit-transform: rotate(-2deg); transform: rotate(-2deg); border-radius: 50% 50% 84% 16% / 88% 16% 84% 12%; } .pants .legBottom .feet.foot2, .pants .legBottomSleeve .feet.foot2 { top: 3.1em; right: -0.5em; -webkit-transform: rotate(0deg); transform: rotate(0deg); border-radius: 50% 50% 14% 86% / 17% 90% 10% 83%; } .pants .legBottom .legBottomSleeve, .pants .legBottomSleeve .legBottomSleeve { top: 0; background: var(--ninjaBlack2); border-top-left-radius: 1em; border-top-right-radius: 1em; } .sword { -webkit-animation: kata4 var(--animationDuration) 1 var(--animationTiming) var(--animationCount); animation: kata4 var(--animationDuration) 1 var(--animationTiming) var(--animationCount); position: absolute; width: 13em; height: 0.5em; left: 7.9em; top: 6.7em; background: var(--ninjaGray); border-bottom-right-radius: 20px; box-shadow: inset 0px -3px 0 0 var(--ninjaGray2); overflow: visible; -webkit-transform: rotate(35deg); transform: rotate(35deg); -webkit-transform-origin: top left; transform-origin: top left; } .sword::before { height: 0.8em; width: 3.5em; left: -3em; top: -2px; background: var(--ninjaBlack2); box-shadow: inset 0 -5px 0 black; border-top-left-radius: 5px; border-bottom-left-radius: 5px; } .sword::after { width: 1.6em; height: 0.5em; border-radius: 1em / 0.5em; left: -5px; top: 0; background: var(--ninjaBlack2); -webkit-transform: rotate(90deg); transform: rotate(90deg); } .star { -webkit-transform-origin: center center; transform-origin: center center; z-index: -1; -webkit-animation: star 2.9s 0.58s; animation: star 2.9s 0.58s; position: absolute; left: -6em; top: 2.5em; display: block; width: 0px; height: 0px; border-left: 100px solid transparent; border-right: 100px solid transparent; border-bottom: 70px solid #fff; -webkit-transform: scale(0.22); transform: scale(0.22); } .star::before { content: ""; position: absolute; top: -45px; left: -65px; display: block; height: 0; width: 0; border-left: 30px solid transparent; border-right: 30px solid transparent; border-bottom: 80px solid #fff; -webkit-transform: rotate(-35deg); transform: rotate(-35deg); } .star::after { content: ""; position: absolute; top: 3px; left: -105px; display: block; width: 0px; height: 0px; border-left: 100px solid transparent; border-right: 100px solid transparent; border-bottom: 70px solid #fff; -webkit-transform: rotate(-70deg); transform: rotate(-70deg); } @-webkit-keyframes eyes { 5% { left: 1.2em; -webkit-transform: translateY(-4px); transform: translateY(-4px); } 95% { left: 1.2em; -webkit-transform: translateY(-4px); transform: translateY(-4px); } 100% { left: 0; -webkit-transform: translateY(0); transform: translateY(0); } } @keyframes eyes { 5% { left: 1.2em; -webkit-transform: translateY(-4px); transform: translateY(-4px); } 95% { left: 1.2em; -webkit-transform: translateY(-4px); transform: translateY(-4px); } 100% { left: 0; -webkit-transform: translateY(0); transform: translateY(0); } } @-webkit-keyframes star { 0% { -webkit-transform: translate(0, 0) scale(0.22) rotate(0deg); transform: translate(0, 0) scale(0.22) rotate(0deg); } 100% { -webkit-transform: translate(-50vw, 250vw) scale(0.22) rotate(-2500deg); transform: translate(-50vw, 250vw) scale(0.22) rotate(-2500deg);.........完整代码请登录后点击上方下载按钮下载查看
网友评论0