Created
November 29, 2012 07:01
-
-
Save joekarma/4167290 to your computer and use it in GitHub Desktop.
A CodePen by Joe Taylor. CSS3 Hourglass - Hourglass (actually, minuteglass) animation using only CSS3 + HTML.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#hour-glass | |
#glass | |
#top-sand | |
#bottom-sand |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Hourglass animation using CSS3. | |
2012 Joe Taylor | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 50px; | |
} | |
#hour-glass { | |
position: relative; | |
width: 60px; | |
height: 120px; | |
overflow: visible; | |
display: table; | |
} | |
#glass { | |
position: absolute; | |
width: 0; height: 0; | |
border-top: solid #c0c0c0 120px; | |
border-left: solid transparent 60px; | |
border-right: solid transparent 60px; | |
} | |
#glass::after { | |
content: ""; | |
position: absolute; | |
left: -60px; bottom: -120px; | |
border-bottom: solid #c0c0c0 120px; | |
border-left: solid transparent 60px; | |
border-right: solid transparent 60px; | |
} | |
#glass::before { | |
z-index: 1; | |
content: ""; | |
position: absolute; | |
top: -10px; left: -6px; | |
width: 12px; height: 20px; | |
background-color: #303030; | |
border-radius: 3px; | |
} | |
#top-sand { | |
display: block; | |
position: absolute; | |
width: 0; | |
height: 0; | |
border-top: solid #422608 3px; | |
border-left: solid transparent 2px; | |
border-right: solid transparent 2px; | |
right: -2px; | |
margin-left: auto; margin-right: auto; | |
position: absolute; bottom: 0; | |
animation: drain 60s ease-in; | |
} | |
#bottom-sand { | |
position: absolute; | |
bottom: -120px; | |
border-bottom: solid #422608 100px; | |
border-left: solid transparent 48px; | |
border-right: solid transparent 48px; | |
right: -48px; | |
animation: fill 60s ease-out; | |
} | |
@keyframes fill { | |
0% { | |
border-bottom: solid #422608 2px; | |
border-left: solid transparent 2px; | |
border-right: solid transparent 2px; | |
right: -2px; | |
} | |
100% { | |
border-bottom: solid #422608 100px; | |
border-left: solid transparent 48px; | |
border-right: solid transparent 48px; | |
right: -48px; | |
} | |
} | |
@keyframes drain { | |
0% { | |
border-top: solid #422608 100px; | |
border-left: solid transparent 48px; | |
border-right: solid transparent 48px; | |
right: -48px; | |
} | |
100% { | |
border-top: solid #422608 3px; | |
border-left: solid transparent 2px; | |
border-right: solid transparent 2px; | |
right: -2px; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment