css+div布局实现卡通大头娃娃跳跃动画效果代码
代码语言:html
所属分类:动画
代码描述:css+div布局实现卡通大头娃娃跳跃动画效果代码,按空格键触发
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");
:root {
--head-width: 200px;
--eye-width: 57px;
--eye-width-inside: calc(var(--eye-width) - 13px);
--skip-color: #ff0059;
--background: #ced3d7;
--body-height: 165px;
--angriness: 3deg;
--animation-duration: 1000ms;
--animation-type: ease;
}
body {
height: 100vh;
width: 100vw;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
overflow: hidden;
background-color: var(--background);
font-family: "Press Start 2P", cursive;
}
.container {
display: flex;
justify-content: center;
}
#text {
opacity: 0;
font-size: 1rem;
animation: text-animation 1.2s ease-out infinite;
text-shadow: 1px 1px black;
color: #3f51b5;
position: absolute;
top: 10%;
text-align:center;
}
#text.stop {
animation: none;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
main {
height: 650px;
width: 410px;
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
scale: 0.5;
}
.shadow {
width: 60%;
height: 4px;
background-color: black;
opacity: 0.2;
transform: translate(0px, 10px);
}
.animate .shadow {
animation: shadow var(--animation-duration) var(--animation-type);
}
.head {
width: var(--head-width);
height: calc(var(--head-width) - 12px);
background-color: var(--skip-color);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.face {
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
margin-top: 50px;
}
.animate .face {
animation: jump-face var(--animation-duration) var(--animation-type);
}
.eyes-wrapper {
display: flex;
align-self: stretch;
justify-content: space-between;
padding-left: 30px;
padding-right: 30px;
}
.eye {
width: var(--eye-width);
height: var(--eye-width);
position: relative;
border-top: solid 4px black;
transform: rotate(var(--angriness));
overflow: hidden;
}
.eye::before,
.eye::after {
content: "";
position: absolute;
border-bottom-left-radius: calc(var(--eye-width) * 2);
border-bottom-right-radius: calc(var(--eye-width) * 2);
top: 0;
}
.eye::before {
background-color: white;
right: 4px;
width: var(--eye-width-inside);
height: calc(var(--eye-width-inside) / 2);
}
.eye::after {
border-radius: 50%;
transform: translateY(calc(var(--eye-width-inside) / 4 * -1));
background-color: black;
right: calc(var(--eye-width-inside) / 4 + 4px);
width: calc(var(--eye-width-inside) / 2);
height: calc(var(--eye-width-inside) / 2);
}
.animate .eye::after {
animation: jump-eyes var(--animation-duration) var(--animation-type);
}
.eye--right {
transform: rotate(calc(var(--angriness) * -1));
}
.eye--right::before {
right: 0px;
left: 4px;
}
.eye--right::after {
right: 0;
left: calc(var(--eye-width-inside) / 4 + 4px);
}
.animate .eye--right::after {
animation: jump-eyes var(--animation-duration) var(--animation-type);
}
.mouth {
width: 35px;
height: 3px;
margin-top: -15px;
background-color: black;
}
.body-wrapper {
height: var(--body-height);
position: relative;
margin-top: -20px;
z-index: -1;
}
.body {
backg.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0