Last active
August 29, 2015 14:15
-
-
Save jasonkmccoy/589b0195094f9b2200ab to your computer and use it in GitHub Desktop.
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
button { | |
background: #e5ac8e; | |
color: #fff; | |
font-size: 14px; | |
border-radius: 0.5em; | |
padding: 0 1em; | |
position: relative; | |
overflow: hidden; | |
line-height: 32px; | |
} | |
.pebble::before { | |
content: ""; | |
} | |
button::after { | |
content: ''; | |
position: absolute; | |
top: -50%; | |
right: -50%; | |
bottom: -50%; | |
left: -50%; | |
background: linear-gradient(to bottom, rgba(229, 172, 142, 0), rgba(255, 255, 255, 0.5) 50%, rgba(229, 172, 142, 0)); | |
transform: rotateZ(60deg) translate(-5em, 7.5em); | |
} | |
button:hover::after, button:focus::after { | |
animation: sheen 1s forwards; | |
} | |
@keyframes sheen { | |
100% { | |
transform: rotateZ(60deg) translate(1em, -9em); | |
} | |
} |
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
<!-- HTML code --> | |
<button>Oooh SHINY</button> |
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
/* See: https://cssanimation.rocks/pseudo-elements/ */ | |
/* Sass code */ | |
// General styles | |
button | |
background: #e5ac8e | |
color: #fff | |
font-size: 14px | |
border-radius: 0.5em | |
padding: 0 1em | |
position: relative | |
overflow: hidden | |
line-height: 32px | |
// Example: Shiny button | |
.pebble::before | |
content: "" | |
button::after | |
content: '' | |
position: absolute | |
top: -50% | |
right: -50% | |
bottom: -50% | |
left: -50% | |
background: linear-gradient(to bottom, rgba(229, 172, 142, 0), rgba(255, 255, 255, 0.5) 50%, rgba(229, 172, 142, 0)) | |
transform: rotateZ(60deg) translate(-5em, 7.5em) | |
button:hover::after, button:focus::after | |
animation: sheen 1s forwards | |
@keyframes sheen | |
100% | |
transform: rotateZ(60deg) translate(1em, -9em) |
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
/* See: https://cssanimation.rocks/pseudo-elements/ */ | |
/* SCSS code */ | |
// General styles | |
button { | |
background: #e5ac8e; | |
color: #fff; | |
font-size: 14px; | |
border-radius: 0.5em; | |
padding: 0 1em; | |
position: relative; | |
overflow: hidden; | |
line-height: 32px; | |
} | |
// Example: Shiny button | |
.pebble::before { | |
content: ""; | |
} | |
button::after { | |
content: ''; | |
position: absolute; | |
top: -50%; | |
right: -50%; | |
bottom: -50%; | |
left: -50%; | |
background: linear-gradient(to bottom, rgba(229, 172, 142, 0), rgba(255,255,255,0.5) 50%, rgba(229, 172, 142, 0)); | |
transform: rotateZ(60deg) translate(-5em, 7.5em); | |
} | |
button:hover::after, button:focus::after { | |
animation: sheen 1s forwards; | |
} | |
@keyframes sheen { | |
100% { | |
transform: rotateZ(60deg) translate(1em, -9em); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Credit: https://cssanimation.rocks/pseudo-elements/
Animating pseudo-elements
Pseudo-elements are like getting extra DOM elements for free. They allow us to add extra content, decoration and more to our pages without adding extra HTML, and they can be animated. In this post we’ll use a pseudo-element to add a little visual flair to a button.