Skip to content

Instantly share code, notes, and snippets.

@Go7hic
Last active February 7, 2017 01:56
Show Gist options
  • Save Go7hic/6811750 to your computer and use it in GitHub Desktop.
Save Go7hic/6811750 to your computer and use it in GitHub Desktop.
CSS 画的头像 #tags: cssdemo
<h1>cssfaces.com</h1>
<!--class .demo just for this demo-->
<div class="demo">
<span class="hair"></span>
<header>
<span class="eyes"></span>
<span class="nose"></span>
<span class="accessoire"></span>
</header>
</div>
//http://cssfaces.com/face/_jotavejv
//see the gallery: http://cssfaces.com/gallery
@hat-color: #004C66;
@face: black;
@body: black;
@tie: #004C66;
@shirt: white;
@bg:#BFEAE2;
.sizing(){
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.hair{
.sizing();
position: absolute;
left: 42px;
top: 55px;
width: 120px;
border-style: solid;
border-color: transparent;
border-bottom-color: @hat-color;
border-width: 0 20px 13px 20px;
z-index: 5;
}
.hair:before{
content:'';
position: absolute;
left: -10px;
top: -48px;
width: 100px;
height:40px;
background: linear-gradient(-70deg, @hat-color 50%, transparent 50%) 0 0 no-repeat
,linear-gradient(70deg, @hat-color 50%, transparent 50%) no-repeat right center;
background-size: 50px 100%;
}
header{
position: absolute;
left: 72px;
top: 25px;
border-style: solid;
border-color: @face;
border-width: 50px 30px 50px 30px;
border-radius: 50%;
&:hover{
.accessoire:after{
border-color: @body;
border-left-color: @shirt;
border-right-color: @shirt;
}
}
}
header:before{
content:'';
position: absolute;
left: -30px;
top: -30px;
width: 60px;
height: 10px;
background: @bg;
}
.eyes{
position: absolute;
left: -24px;
width: 20px;
height: 20px;
border-bottom-left-radius: 80%;
border-top-right-radius: 80%;
background: linear-gradient(45deg,#eee 20%, #BFFFFF);
}
.eyes:before{
content:'';
position: absolute;
left: 28px;
width: 20px;
height: 20px;
border-bottom-right-radius: 80%;
border-top-left-radius: 80%;
background: linear-gradient(-45deg, #eee 20%, #BFFFFF);;
}
.accessoire{
position: absolute;
top: 71px;
left: -77px;
width: 133px;
border-style: solid;
border-color: @body;
border-left-color: transparent;
border-right-color: transparent;
border-width: 65px 10px 0 10px;
}
.accessoire:before{
content:'';
position: absolute;
top: -80px;
left: -12px;
width: 40px;
border-style: solid;
border-color: @body;
border-left-color: transparent;
border-right-color: transparent;
border-width: 0 58px 15px 58px;
}
.accessoire:after{
content:'';
position: absolute;
top: -80px;
left: 58px;
width: 5px;
border-style: solid;
border-color: @tie;
border-left-color: @shirt;
border-right-color: @shirt;
border-width: 10px 6px 45px 6px;
z-index: 4;
transition: all .5s linear;
}
/*here is a shirt's details*/
.nose{
position: absolute;
top: 69px;
left: -29px;
width: 15px;
border-style: solid;
border-color: @shirt;
border-left-color: transparent;
border-right-color: transparent;
border-width: 42px 21px 0 21px;
z-index: 3;
}
.nose:before{
content:'';
position: absolute;
top: -57px;
left: -22px;
width: 29px;
border-style: solid;
border-color: @shirt;
border-left-color: transparent;
border-right-color: transparent;
border-width: 0 15px 15px 15px;
z-index: 3;
}
body{overflow: hidden;}
.demo{
text-align: center;
position: absolute;
top: 0; bottom: 0;
left: 0; right: 0;
margin: auto;
width: 200px;
height: 200px;
background: @bg;
box-shadow: 0 0 0 0 rgba(0,0,0,.6);
transform: scale(10); opacity: 0;
animation: in 1s 1s ease-in forwards;
&:after{
content:'@Go7hic';
width: 100%;
height: 40px;
background: @bg;
position: absolute;
left: 0;
bottom: -40px;
color: rgb(32, 80, 150);
font-weight: bold;
line-height: 40px;
}
}
h1{
color: #F1614B;
font-size: 32px;
text-align: center;
text-shadow: 1px 1px 0 black;
&:before{
animation: bd 1s ease forwards;
//transform-origin: center center;
transform: scaleY(0);
position: absolute;
content:'';
width: 140px;
height: 40px;
border-top: solid 1px;
border-bottom: solid 1px;
}
}
@keyframes in{
from{
transform: scale(10); opacity: 0;
box-shadow: 0 30px 0 0 rgba(0,0,0,.5);
}
50%{
transform: scale(1); opacity: 1;
box-shadow: 0 30px 0 0 rgba(0,0,0,.5);
}
to{
transform: scale(1); opacity: 1;
box-shadow: 0 30px 500px 20px rgba(0,0,0,0);
}
}
@keyframes bd{
to{
transform: scaleY(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment