Created
April 12, 2013 16:16
-
-
Save derekpcollins/5373192 to your computer and use it in GitHub Desktop.
A CodePen by Derek P. Collins. Basic Popover Animation - Popover slides up and fades in on hover of an element. Just CSS, no JavaScript.
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
<div class="center"> | |
<span class="qs">? <span class="popover above">Hey bro, cool popover.</span></span> | |
</div> |
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
@import "compass"; | |
body { | |
background-color: #e3fbff; | |
} | |
/* Just to center things */ | |
.center { | |
margin: 100px auto; | |
width: 30px; | |
} | |
/* The element to hover over */ | |
.qs { | |
background-color: #02bdda; | |
border-radius: 16px; | |
color: #e3fbff; | |
cursor: default; | |
display: inline-block; | |
font-family: 'Helvetica',sans-serif; | |
font-size: 18px; | |
font-weight: bold; | |
height: 30px; | |
line-height: 30px; | |
position: relative; | |
text-align: center; | |
width: 30px; | |
.popover { | |
background-color: rgba(0,0,0,0.85); | |
border-radius: 5px; | |
bottom: 42px; | |
box-shadow: 0 0 5px rgba(0,0,0,0.4); | |
color: #fff; | |
display: none; | |
font-size: 12px; | |
font-family: 'Helvetica',sans-serif; | |
left: -95px; | |
padding: 7px 10px; | |
position: absolute; | |
width: 200px; | |
z-index: 4; | |
&:before { | |
border-top: 7px solid rgba(0,0,0,0.85); | |
border-right: 7px solid transparent; | |
border-left: 7px solid transparent; | |
bottom: -7px; | |
content: ''; | |
display: block; | |
left: 50%; | |
margin-left: -7px; | |
position: absolute; | |
} | |
} | |
&:hover { | |
.popover { | |
display: block; | |
-webkit-animation: fade-in .3s linear 1, move-up .3s linear 1; | |
-moz-animation: fade-in .3s linear 1, move-up .3s linear 1; | |
-ms-animation: fade-in .3s linear 1, move-up .3s linear 1; | |
} | |
} | |
} | |
@-webkit-keyframes fade-in { | |
from { opacity: 0; } | |
to { opacity: 1; } | |
} | |
@-moz-keyframes fade-in { | |
from { opacity: 0; } | |
to { opacity: 1; } | |
} | |
@-ms-keyframes fade-in { | |
from { opacity: 0; } | |
to { opacity: 1; } | |
} | |
@-webkit-keyframes move-up { | |
from { bottom: 30px; } | |
to { bottom: 42px; } | |
} | |
@-moz-keyframes move-up { | |
from { bottom: 30px; } | |
to { bottom: 42px; } | |
} | |
@-ms-keyframes move-up { | |
from { bottom: 30px; } | |
to { bottom: 42px; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment