<div class="wrapper">
<!-- <h1 class="title">Avatar with HTML + CSS</h1> -->
<div class="avatar">
<div class="inner">
<div class="hair-side"></div>
<div class="hair-above"></div>
<div class="head">
<div class="face">
<div class="eyes">
<div class="eye-left"></div>
<div class="eye-right"></div>
</div>
<div class="nose"></div>
<div class="mouth"></div>
</div>
</div>
<div class="ears">
<div class="ear-left"></div>
<div class="ear-right"></div>
</div>
<div class="neck"></div>
</div>
<div class="body"></div>
</div>
</div>
/* Vars */
$skin: #daa4a4;
$border: 4px solid #2B1945;
$hair: #2B1945;
.wrapper {
position: absolute;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
color: #f5f7fa;
font-family: 'Titillium Web', sans-serif;
background-image: linear-gradient(to bottom, #6087f5 0%, #abfbd7 100%);
}
.title {
font-size: 48px;
margin-bottom: 50px;
}
/* ************************ */
%eye {
position: relative;
width: 33px;
height: 33px;
border-radius: 100%;
background-color: #fff;
&::before {
content: "";
position: absolute;
width: 35px;
height: 7px;
background-color: $hair;
border-radius: 3px;
}
&::after {
content: "";
position: absolute;
left: 3px;
bottom: 0;
width: 80%;
height: 80%;
border-radius: 100%;
background-color: #0c2a3c;
}
}
.avatar {
position: relative;
width: 500px;
height: 500px;
background-image: linear-gradient(to top, #c3cfe2 0%, #f5f7fa 100%);
border-radius: 100%;
box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
overflow: hidden;
}
.inner {
position: relative;
top: 30%;
width: 200px;
height: 65%;
margin: 0 auto;
z-index: 2;
}
.head {
position: absolute;
background-color: $skin;
width: 145px;
height: 230px;
left: 50%;
transform: translateX(-50%);
border-radius: 100px;
border: $border;
z-index: 1;
}
.hair-side {
position: absolute;
left: 0;
top: -10px;
width: 100%;
height: 100px;
background-color: $hair;
border-radius: 100%;
z-index: 0;
&::before,
&::after {
content: "";
position: absolute;
background-color: $hair;
top: 50px;
width: 80px;
height: 80px;
border-radius: 100%;
}
&::before { left: 10px; }
&::after { right: 10px; }
}
.hair-above {
position: absolute;
background-color: $hair;
left: 10px;
top: -30px;
width: 80px;
height: 80px;
border-radius: 100%;
z-index: 2;
&::before,
&::after {
content: "";
position: absolute;
background-color: $hair;
border-radius: 100%;
z-index: 2;
}
&::before {
left: 30px;
top: -30px;
width: 120px;
height: 120px;
}
&::after {
left: 120px;
top: 20px;
width: 60px;
height: 60px;
}
}
.face {
position: relative;
top: 50px;
width: 100px;
height: 120px;
margin: 0 auto;
&::before,
&::after {
content: "";
position: absolute;
top: 33%;
width: 25px;
height: 30px;
border-radius: 100%;
background-color: darken($skin, 5%);
}
&::before { right: -15px; }
&::after { left: -15px; }
}
.ears {
position: absolute;
left: 0;
top: 28%;
z-index: 0;
width: 100%;
display: flex;
justify-content: space-between;
}
.ear-left,
.ear-right {
position: relative;
width: 45px;
height: 40px;
background-color: $skin;
border: $border;
border-radius: 100%;
&::before {
content: "";
position: absolute;
top: 15px;
width: 5px;
height: 5px;
border-top: $border;
border-right: $border;
border-width: 3px;
}
}
.ear-left {
left: 5px;
&::before {
left: 5px;
transform: rotate(45deg);
}
}
.ear-right {
right: 5px;
&::before {
right: 5px;
transform: rotate(-135deg);
}
}
.eyes {
margin-top: 30px;
width: 100%;
display: flex;
justify-content: space-between;
}
.eye-left {
@extend %eye;
&::before {
left: -5px;
top: -10px;
transform: rotate(-10deg);
}
}
.eye-right {
@extend %eye;
&::before {
right: -5px;
top: -20px;
transform: rotate(20deg);
}
}
.nose {
position: relative;
width: 20px;
height: 20px;
border-top: $border;
border-right: $border;
margin: 0 auto;
transform: rotate(45deg);
border-radius: 4px;
&::before {
content: "";
position: absolute;
left: -8px;
top: -19px;
width: 0;
height: 20px;
border-right: $border;
transform: rotate(-45deg);
}
}
.mouth {
width: 70px;
height: 50px;
margin: -10px auto 0;
border-radius: 100%;
border-bottom: $border;
border-width: 12px;
}
.neck {
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 30px;
width: 80px;
height: 90px;
background-color: $skin;
z-index: 0;
border: $border;
border-bottom-left-radius: 50px;
border-bottom-right-radius: 50px;
overflow: hidden;
&::before {
content: "";
position: absolute;
width: 150%;
height: 150px;
right: -15px;
top: -115%;
border-radius: 100px;
background-color: $hair;
}
}
.body {
position: absolute;
bottom: -25px;
left: 50%;
transform: translate(-50%);
width: 300px;
height: 145px;
background-color: #1B559B;
border-top-left-radius: 50px;
border-top-right-radius: 50px;
border: $border;
z-index: 1;
&::before {
content: "";
position: absolute;
top: -20px;
left: 50%;
transform: translate(-50%);
width: 120px;
height: 100px;
border-radius: 100%;
background-color: darken(#1B559B, 10%);
border: $border;
}
&::after {
content: "";
position: absolute;
bottom: -70px;
left: 50%;
transform: translate(-50%);
width: 180px;
height: 100px;
border-radius: 100%;
background-color: #fff;
border: $border;
border-width: 2px;
}
}
View Compiled
This Pen doesn't use any external JavaScript resources.