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 {
-we.........完整代码请登录后点击上方下载按钮下载查看
网友评论0