Skip to content

Instantly share code, notes, and snippets.

@CodeMyUI
Forked from anonymous/Pure CSS Moonwalk.markdown
Created September 29, 2015 03:43
Show Gist options
  • Select an option

  • Save CodeMyUI/e81c5c160de7d9e6f191 to your computer and use it in GitHub Desktop.

Select an option

Save CodeMyUI/e81c5c160de7d9e6f191 to your computer and use it in GitHub Desktop.
Pure CSS Moonwalk
<div class="container">
<header>
<h1>Pure <strong>CSS</strong> Moonwalk</h1>
<p>... just for laughts.</p>
</header>
<section>
<article class="Legs-move">
<div class="leg">
<div class="articulation">
<div class="bone finger point">
<svg version="1.1" id="finger-layer" class="finger-layer" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="54px" height="27px" viewBox="0 0 54 27" enable-background="new 0 0 54 27" xml:space="preserve">
<path id="finger" d="M44.967,4.903l-0.01-0.012L15.735,0.585l-0.001,0.014C15.165,0.524,14.59,0.473,14,0.473
c-7.336,0-13.283,5.946-13.283,13.283c0,7.335,5.947,13.281,13.283,13.281h34.719c2.209,0,4-1.791,4-4v-9.23
C52.719,9.26,49.346,5.512,44.967,4.903z" />
<!-- <circle id="screw_4_" opacity="0.5" fill="#218282" cx="14" cy="13.755" r="5.645"/> -->
</svg>
</div>
<div class="bone palm point">
<svg version="1.1" id="palm-svg" class="palm-svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="103px" height="50px" viewBox="0 0 103 50" enable-background="new 0 0 103 50" xml:space="preserve">
<path id="palm" d="M90.733,22.599l0.001-0.014L51.491,9.732l-3.086-8.858l-3.456-0.127C41.535,23.542,7.249,22.473,6,7.59
c-2.177-0.372-4,1.791-4,4L0,45.037c0,2.209,1.791,4,4,4h30.949c2.19,0,3.964-1.762,3.995-3.945l48.175,3.797
c0.616,0.088,1.24,0.148,1.88,0.148c7.336,0,13.282-5.946,13.282-13.281C102.281,29.009,97.248,23.45,90.733,22.599z" />
<!-- <circle id="screw_2_" opacity="0.5" fill="#218282" cx="20.188" cy="35.755" r="6.05"/> -->
<!-- <circle id="screw_3_" opacity="0.5" fill="#218282" cx="88.999" cy="35.755" r="5.645"/> -->
</svg>
<div class="bone point">
<svg version="1.1" id="bone-down-layer" class="bone-down-layer" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="232px" height="80px" viewBox="0 0 232 80" enable-background="new 0 0 232 80" xml:space="preserve">
<g id="bone-down">
<path id="sock" fill="#FFFFFF" d="M136.76,14.155l0.383,32.358l77.517-0.945l-0.054-4.514c2.014,0.666,4.216,0.848,6.449,0.412
c6.932-1.346,10.292-8.061,8.945-14.993c-1.347-6.935-6.893-11.462-13.826-10.114c-0.642,0.125-1.256,0.31-1.854,0.521
l-0.042-3.671L136.76,14.155z" />
<path id="bone_2_" fill="#333333" d="M26.572,5.797L26.349,5.8v0.001c-1.543,0.026-3.103,0.18-4.671,0.484
C7.153,9.109-2.332,23.17,0.491,37.694c2.485,12.782,13.676,21.657,26.224,21.677l-0.001,0.002l0.878-0.016
c0.086-0.002,0.171,0,0.257-0.004l125.044-2.193l0.129,3.473l10.887-0.521L161.726,1l-10.888,0.521l0.104,2.729L27.111,5.79
C26.932,5.788,26.753,5.795,26.572,5.797z" />
<!-- <circle id="screw_5_" opacity="0.5" fill="#218282" cx="26.788" cy="32.583" r="6.043"/> -->
<!-- <path id="screw_1_" opacity="0.5" fill="#218282" d="M219.765,34.852c-3.276,0.639-6.455-1.504-7.091-4.783 c-0.638-3.281,1.506-6.456,4.785-7.093c3.28-0.639,6.455,1.503,7.094,4.783C225.189,31.04,223.049,34.215,219.765,34.852z"/> -->
</g>
</svg>
<div class="bone bone point">
<svg version="1.1" id="bone-up-layer" class="bone-up-layer" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" <svg version="1.1" id="bone-up-layer" class="bone-up-layer" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px" y="0px" width="183px" height="72px" viewBox="0 0 183 72" enable-background="new 0 0 183 72" xml:space="preserve">
<g id="bone-up">
<path id="bone" fill="#333333" d="M156.394,0.005C156.333,0.004,156.272,0,156.211,0c-0.49,0-0.977,0.015-1.46,0.041L3.174,3.399
L0.211,70.578l150.815-17.504v-0.002c1.678,0.329,3.41,0.506,5.185,0.506c14.796,0,26.789-11.993,26.789-26.789
c0-14.665-11.783-26.569-26.397-26.779V0L156.394,0.005z" />
<!-- <circle id="screw" opacity="0.5" fill="#218282" cx="156.211" cy="26.789" r="6.042"/> -->
</g>
</svg>
</div>
</div>
</div>
</div>
</div>
<div class="leg">
<div class="articulation">
<div class="bone finger point">
<svg version="1.1" id="finger-layer" class="finger-layer" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="54px" height="27px" viewBox="0 0 54 27" enable-background="new 0 0 54 27" xml:space="preserve">
<path id="finger" d="M44.967,4.903l-0.01-0.012L15.735,0.585l-0.001,0.014C15.165,0.524,14.59,0.473,14,0.473
c-7.336,0-13.283,5.946-13.283,13.283c0,7.335,5.947,13.281,13.283,13.281h34.719c2.209,0,4-1.791,4-4v-9.23
C52.719,9.26,49.346,5.512,44.967,4.903z" />
<!-- <circle id="screw_4_" opacity="0.5" fill="#218282" cx="14" cy="13.755" r="5.645"/> -->
</svg>
</div>
<div class="bone palm point">
<svg version="1.1" id="palm-svg" class="palm-svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="103px" height="50px" viewBox="0 0 103 50" enable-background="new 0 0 103 50" xml:space="preserve">
<path id="palm" d="M90.733,22.599l0.001-0.014L51.491,9.732l-3.086-8.858l-3.456-0.127C41.535,23.542,7.249,22.473,6,7.59
c-2.177-0.372-4,1.791-4,4L0,45.037c0,2.209,1.791,4,4,4h30.949c2.19,0,3.964-1.762,3.995-3.945l48.175,3.797
c0.616,0.088,1.24,0.148,1.88,0.148c7.336,0,13.282-5.946,13.282-13.281C102.281,29.009,97.248,23.45,90.733,22.599z" />
<!-- <circle id="screw_2_" opacity="0.5" fill="#218282" cx="20.188" cy="35.755" r="6.05"/> -->
<!-- <circle id="screw_3_" opacity="0.5" fill="#218282" cx="88.999" cy="35.755" r="5.645"/> -->
</svg>
<div class="bone point">
<svg version="1.1" id="bone-down" class="bone-down-layer" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="232px" height="80px" viewBox="0 0 232 80" enable-background="new 0 0 232 80" xml:space="preserve">
<g id="bone-down">
<path id="sock" fill="#FFFFFF" d="M136.76,14.155l0.383,32.358l77.517-0.945l-0.054-4.514c2.014,0.666,4.216,0.848,6.449,0.412
c6.932-1.346,11.46-8.061,10.113-14.993c-1.347-6.935-8.061-11.462-14.994-10.114c-0.642,0.125-1.256,0.31-1.854,0.521
l-0.042-3.671L136.76,14.155z" />
<path id="bone_2_" fill="#333333" d="M26.572,5.797L26.349,5.8v0.001c-1.543,0.026-3.103,0.18-4.671,0.484
C7.153,9.109-2.332,23.17,0.491,37.694c2.485,12.782,13.676,21.657,26.224,21.677l-0.001,0.002l0.878-0.016
c0.086-0.002,0.171,0,0.257-0.004l125.044-2.193l0.129,3.473l10.887-0.521L161.726,1l-10.888,0.521l0.104,2.729L27.111,5.79
C26.932,5.788,26.753,5.795,26.572,5.797z" />
<!-- <circle id="screw_5_" opacity="0.5" fill="#218282" cx="26.788" cy="32.583" r="6.043"/> -->
<!-- <path id="screw_1_" opacity="0.5" fill="#218282" d="M219.765,34.852c-3.276,0.639-6.455-1.504-7.091-4.783 c-0.638-3.281,1.506-6.456,4.785-7.093c3.28-0.639,6.455,1.503,7.094,4.783C225.189,31.04,223.049,34.215,219.765,34.852z"/> -->
</g>
</svg>
<div class="bone bone point">
<svg version="1.1" id="bone-up-layer" class="bone-up-layer" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="183px" height="72px" viewBox="0 0 183 72" enable-background="new 0 0 183 72" xml:space="preserve">
<g id="bone-up">
<path id="bone" fill="#333333" d="M156.394,0.005C156.333,0.004,156.272,0,156.211,0c-0.49,0-0.977,0.015-1.46,0.041L3.174,3.399
L0.211,70.578l150.815-17.504v-0.002c1.678,0.329,3.41,0.506,5.185,0.506c14.796,0,26.789-11.993,26.789-26.789
c0-14.665-11.783-26.569-26.397-26.779V0L156.394,0.005z" />
<!-- <circle id="screw" opacity="0.5" fill="#218282" cx="156.211" cy="26.789" r="6.042"/> -->
</g>
</svg>
</div>
</div>
</div>
</div>
</div>
<div class="ground"></div>
</article>
</section>
</div>
@import 'compass/reset';
@import 'compass/css3';
@import url(http://fonts.googleapis.com/css?family=Open+Sans:700,300);
$maxScreen: 679px;
$lime: #12ff93;
$navy: #0a4069;
$cyan: #57caf4;
$red: #ec008c;
$white: #fefefe;
$gray: #444444;
$aceleration: ease-in-out;
// $aceleration: cubic-bezier(0.74, -0.39, 0.33, 1.35);
$factor: 1.618;
$base-width: 10em;
$time: 1.5s;
@mixin calc($property, $expression)
{
#{$property}: -webkit-calc(#{$expression});
#{$property}: calc(#{$expression});
}
body,
html
{
overflow: hidden;
height: 100%;
}
body
{
font-family: 'Open Sans', sans-serif;
font-size: 16px;
font-weight: 300;
text-align: center;
color: $gray;
background: #d0d0d0;
}
h1
{
font-size: 2.5em;
margin: 2em 0 .5em;
}
strong
{
font-weight: 700;
}
div
{
position: relative;
}
article,
section
{
position: relative;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: center;
width: 100%;
margin-bottom: 2em;
padding: 0;
text-align: center;
}
section
{
overflow: hidden;
height: 20.7em;
border: 10px solid #434343;
border-left: 0;
border-right: 0;
margin-top: 2em;
}
article
{
margin: -5em 0 0;
}
.container
{
position: relative;
display: inline-block;
width: 100%;
height: 100%;
margin: 0 auto;
}
.Legs-move
{
// $timeUnit: $time /
// animation: moveBack $time linear infinite;
perspective: 900px;
perspective-origin: 50% 100%;
}
.leg
{
$base-width: $base-width + 5;
$finger-width: ($base-width / $factor) / 5;
width: ($base-width / $factor) / 3;
z-index: 2;
.articulation
{
margin-top: $base-width * 1.5;
transition: all .5s ease-in-out;
transform-origin: 0 50%;
svg
{
// opacity: .5;
position: absolute;
left: 0;
z-index: 1;
}
.palm-svg
{
z-index: 2;
}
.bone-down-layer
{
left: -27px;
top: -28px;
}
.bone-up-layer
{
left: 36px;
top: -24px;
}
}
.point:before
{
position: absolute;
top: -.2em;
right: -.4em;
display: inline-block;
width: 0;
height: 0;
content: '';
border: .4em solid black;
border-radius: 50%;
}
.bone
{
$bone-width: $base-width - (($base-width / $factor) / 2);
position: absolute;
top: 0;
left: -$base-width;
display: inline-block;
width: $base-width;
height: .4em;
transform: rotate(-15deg);
transform-origin: 100% 50%;
transition: all .5s ease-in-out;
border-radius: 0;
background-color: $cyan;
&:nth-child(2) > .bone
{
// width: $bone-width;
width: $base-width - 3;
left: -($base-width - 3);
transform: rotate(100deg);
}
}
.palm
{
width: $base-width - ($base-width / $factor) - 1.4;
left: ($base-width - ($base-width / $factor) - 1.4) * -1;
transform: rotate(0deg);
> svg
{
left: -20px;
top: -33px;
}
}
.finger
{
width: $finger-width;
left: 0;
transform: rotate(0deg);
background-color: $red;
> svg
{
left: -14px;
top: -10px;
}
}
&:nth-child(1)
{
margin-left: 10em;
margin-right: -3em;
animation: stepBack $time linear infinite;
.finger
{
}
.palm
{
animation: palmBack $time linear infinite;
}
.bone .bone .bone
{
animation: boneBack $time linear infinite;
}
}
&:nth-child(2)
{
margin-left: 0;
animation: stepBack $time linear infinite;
animation-delay: $time * .5;
.finger
{
}
.palm
{
animation: palmBack $time linear infinite;
animation-delay: $time * .5;
}
.bone > .bone > .bone
{
transform: rotate(-10deg);
animation: boneBack $time linear infinite;
animation-delay: $time * .5;
}
}
}
.leg:nth-child(2)
{
.finger,
.palm-svg
{
fill: lighten(black, 15);
}
}
.leg:nth-child(1)
{
.bone-up-layer g path,
.bone-down-layer g path
{
fill: lighten(black, 15);
}
.bone-down-layer g path#sock
{
fill: darken(white, 05);
}
}
.ground
{
position: absolute;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 16em;
transform: rotateX(67deg) translateY(16em) translateZ(-9em);
&:before
{
content: '';
position: absolute;
z-index: 1;
right: 0;
top: 0;
height: 100%;
width: 200%;
$bg-color: rgba(#eee, .6);
background-color: transparent;
background-image: linear-gradient(45deg, $bg-color 25%, transparent 25%, transparent 75%, $bg-color 75%, $bg-color),
linear-gradient(45deg, $bg-color 25%, transparent 25%, transparent 75%, $bg-color 75%, $bg-color);
background-size: 16em 16em;
background-position:0 0, 8em 8em;
animation: groundBack (($time + .4) * 2) linear infinite;
}
}
input[type='radio']#say-hi:checked ~ .skeleton
{
.arm
{
transform: rotate(60deg);
.bone:nth-child(2)
{
transform: rotate(60deg);
}
.hand
{
animation: hihand ease-in-out .12s infinite alternate;
}
}
}
@keyframes hihand
{
0%
{
transform: rotate(170deg);
}
100%
{
transform: rotate(130deg);
}
}
@keyframes moveBack
{
0%
{
transform: translate(0em);
}
12.5%
{
transform: translate(0em);
}
25%
{
transform: translate(-4em);
}
50%
{
transform: translate(-4em);
}
100%
{
transform: translate(-4em);
}
}
@keyframes stepBack
{
0%
{
transform: translate(0em);
}
50%
{
transform: translate(-4em);
}
100%
{
transform: translate(0em);
}
}
@keyframes groundBack
{
0%
{
transform: translate(0em);
}
100%
{
transform: translate(16em);
}
}
@keyframes palmBack
{
0%
{
transform: rotate(20deg);
}
45%
{
transform: rotate(20deg);
}
50%
{
transform: rotate(0deg);
}
95%
{
transform: rotate(0deg);
}
100%
{
transform: rotate(20deg);
}
}
@keyframes boneBack
{
0%
{
transform: rotate(-50deg);
}
45%
{
transform: rotate(-30deg);
}
50%
{
transform: rotate(-10deg);
}
95%
{
transform: rotate(-10deg);
}
100%
{
transform: rotate(-50deg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment