div+css实现公鸡行走动画效果代码
代码语言:html
所属分类:动画
代码描述:div+css实现公鸡行走动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
*,
*::after,
*::before {
padding: 0;
margin: 0;
box-sizing: border-box;
}
:root {
--color-bg: #f0693e;
--color-1: #f3c074;
--color-2: #753d22;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: var(--color-bg);
overflow: hidden;
}
.rooster {
position: relative;
animation: body-ans 0.6s linear infinite;
}
.rooster__head {
width: 3rem;
height: 3rem;
background-color: var(--color-2);
margin-left: 1.5rem;
--radius: 10rem;
border-top-left-radius: var(--radius);
border-bottom-left-radius: var(--radius);
}
.rooster__head--wing {
--h: 1.6rem;
--w: calc(var(--h) * 2);
position: absolute;
top: calc(var(--h) * -0.9);
left: 1rem;
width: var(--w);
height: var(--h);
border-radius: 0 0 4rem 4rem;
border-left: 0.8rem solid #c71e24;
background-color: #d52026;
animation: ans-wing-1 0.4s infinite;
}
@keyframes ans-wing-1 {
0%,
100% {
transform: rotate(0deg);
}
50% {
transform: rotate(10deg);
}
}
.rooster__head--wing--2 {
--h: 2.8rem;
--w: calc(var(--h) / 2);
position: absolute;
top: calc(var(--h) * -1);
left: 2.8rem;
width: var(--w);
height: var(--h);
border-radius: 0 4rem 4rem 0;
background-color: #a21f21;
border-right: 4px solid #991c1e;
transform-origin: bottom;
transform: rotate(-10deg);
animation: ans-wing-2 0.4s ease-in-out infinite;
}
@keyframes ans-wing-2 {
0%,
100% {
transform: rotate(-10deg);
}
50% {
transform: rotate(-20deg);
}
}
.rooster__head--wing--3 {
--h: 1.2rem;
--w: calc(var(--h) * 2);
position: absolute;
top: -0.4rem;
left: 2.6rem;
width: var(--w);
height: var(--h);
border-radius: 0 0 4rem 4rem;
background-color: #a21f21;
border-right: 4px solid #991c1e;
transform-origin: bottom;
--rotate: 15deg;
transform: rotate(var(--rotate));
animation: ans-wing-3 0.5s infinite;
}
.rooster__head--wing--4 {
--h: 2.8rem;
--w: calc(var(--h) / 2);
position: absolute;
top: calc(var(--h) * -0.9);
left: 2.4rem;
width: var(--w);
height: var(--h);
border-radius: 4rem 0 2rem 0;
background-color: #d52026;
border-right: 8px solid #c71e24;
transform-origin: bottom;
--rotate: 10deg;
transform: rotate(var(--rotate));
animation: ans-wing-3 0.4s infinite;
}
@keyframes ans-wing-3 {
0%,
100% {
transform: rotate(var(--rotate));
}
50% {
transform: rotate(calc(var(--rotate) + 15deg));
}
}
.rooster__eyes {
position: absolute;
top: 0.3rem;
left: 0.8rem;
display: flex;
align-items: center;
}
.rooster__eye {
--s: 1.4rem;
width: var(--s);
height: var(--s);
border-radius: 50%;
background-color: #fff;
position: relative;
overflow: hidden;
}
.rooster__eye--1 {
border: 4px solid var(--color-2);
box-sizing: content-box;
}
.rooster__eye--2 {
margin-left: -0.2rem;
}
.rooster__eye::after {
content: "";
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 0.4rem;
height: 0.4rem;
border-radius: 50%;
background-color: #000;
}
.rooster__eye-ans {
position: absolute;
width: 100%;
height: 100%;
top: 0%;
left: 0;
background-color: #753d22;
transform: translateY(-70%);
z-index: 2;
animation: eye-ans 1.2s infinite;
}
.rooster__eye-ans--d {
position: absolute;
width: 100%;
height: 100%;
top: 0%;
left: 0;
background-color: #753d22;
border-radius: inherit;
transform: translateY(100%);
z-index: 2;
animation: eye-ans-d 1.2s infinite;
}
@keyframes eye-ans {
0%,
85%,
100% {
transform: translateY(-70%);
}
95% {
transform: translateY(-40%);
}
}
@keyframes eye-ans-d {
0%,
85%,
100% {
transform: translateY(100%);
}
95% {
transform: translateY(40%);
}
}
.rooster__mouth {
position: absolute;
width: 1.4rem;
height: 0.9rem;
left: 1rem;
top: 2rem;
border-radius: 50%;
background-color: yellow;
transform: rotate(2deg);
z-index: 100;
}
.rooster__mouth-d {
position: absolute;
top: 2.97rem;
left: 1.55rem;
width: 0.9rem;
height: 0.9rem;
background-color: #991c1e;
border-radius: 50%;
z-index: 2;
transform-origin: top;
animation: mouth-ans 0.5s ease-in-out infinite;
}
.rooster__mouth-d--shadow {
top: 2.97rem;
left: 1.66rem;
transform: scale(1.1);
background-color: #7e0404;
}
.rooster__mouth-d::after {
content: "";
position: absolute;
top: -0.1rem;
left: 0.15rem;
width: 0.4rem;
height: 0.5rem;
transform: rotate(35deg);
background-color: #991c1e;
}
.rooster__mouth-d::before {
content: "";
p.........完整代码请登录后点击上方下载按钮下载查看
网友评论0