星球大战尤达(Baby Yoda)
程序员文章站
2022-04-01 17:21:30
...
示例
HTML
<div class="wrapper">
<div class="circle">
<div class="inner-circle">
<div class="bottom-border"></div>
<div class="chest"></div>
<div class="head">
<div class="eyes"></div>
<div class="l-ear"></div>
<div class="r-ear"></div>
</div>
</div>
</div>
</div>
CSS
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background: #FFE9D0;
}
.wrapper {
display: flex;
align-items: center;
justify-content: center;
height: 60vmin;
width: 60vmin;
animation: fadeIn 1s ease;
}
.circle {
display: flex;
align-items: center;
justify-content: center;
height: 50vmin;
width: 50vmin;
background: #958D74;
border-radius: 100%;
}
.inner-circle {
height: 35vmin;
width: 35vmin;
background: #FFE9D0;
border-radius: 100%;
}
.bottom-border {
margin-top: 24vmin;
height: 15vmin;
width: 35vmin;
background: #958D74;
border-radius: 0 0 50% 50%;
}
.chest {
position: relative;
bottom: 25vmin;
left: 0vmin;
width: 0;
height: 0;
border-left: 17vmin solid transparent;
border-right: 17vmin solid transparent;
border-bottom: 15vmin solid #958D74;
}
.head {
position: relative;
bottom: 52vmin;
left: 7.5vmin;
height: 20vmin;
width: 20vmin;
background: #958D74;
border-radius: 100%;
z-index: 2;
}
.eyes {
position: relative;
top: 6vmin;
left: 3.5vmin;
height: 5.5vmin;
width: 5.5vmin;
background: #FFE9D0;
border-radius: 100%;
z-index: 2;
animation: blink 2s alternate infinite;
}
.eyes::after {
content: "";
position: absolute;
left: 7vmin;
height: 5.5vmin;
width: 5.5vmin;
background: #FFE9D0;
border-radius: 100%;
z-index: 2;
animation: blink 2s alternate infinite;
}
.l-ear {
position: relative;
top: -3vmin;
right: 18vmin;
height: 10vmin;
width: 25vmin;
background: #958D74;
border-radius: 5% 0 0 95%;
z-index: 1;
animation: ear-movement-left 3s ease-in-out infinite alternate;
transform-origin: top right;
}
.r-ear {
position: relative;
bottom: 13vmin;
left: 13vmin;
height: 10vmin;
width: 25vmin;
background: #958D74;
border-radius: 0 5% 95% 0;
z-index: 1;
animation: ear-movement-right 3s ease-in-out infinite alternate;
transform-origin: top left;
}
/* keyframes */
@keyframes blink {
0% {
background: #958D74;
}
20%, 100% {
background: #FFE9D0;
}
100% {
background: #FFE9D0;
}
}
@keyframes ear-movement-right {
0% {
transform: translateY(0vmin);
}
100% {
transform: translateY(1.5vmin);
transform: rotate(5deg);
}
}
@keyframes ear-movement-left {
0% {
transform: translateY(0vmin);
}
100% {
transform: translateY(1.5vmin);
transform: rotate(-5deg);
}
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
推荐阅读