Skip to content

Instantly share code, notes, and snippets.

@a-h-abid
Created September 14, 2014 09:22
Show Gist options
  • Save a-h-abid/14cf849b97831daa8835 to your computer and use it in GitHub Desktop.
Save a-h-abid/14cf849b97831daa8835 to your computer and use it in GitHub Desktop.
A pure text reflection done in CSS3 by Yichuan Shen, only mention the classname and you are done.
/**
* CSS3 Snippet By Yichuan Shen
*
* Places a reflected mirror text vertically.
*
* Requires CSS3 support with gradient and transform properties,
* along with psudo-elements :before and :after.
*
* Usage: <h1 class="text-reflect" data-text="Reflect">Reflect</h1>;
* URL : yichuanshen.de/blog/2011/01/08/reflecting-text-with-pure-css3/
*/
.text-reflect {
position: relative;
}
.text-reflect:before, .text-reflect:after {
display: block;
position: absolute;
bottom: -.8em; /* You should change this value to fit your font */
left: 0;
right: 0;
}
.text-reflect:before {
content: attr(data-text);
opacity: .3;
/* This is how the text is flipped vertically */
-webkit-transform: scaleY(-1);
-moz-transform: scaleY(-1);
-o-transform: scaleY(-1);
transform: scateY(-1);
}
.text-reflect:after {
/* Fading using CSS gradient */
/* Don't forget to change the colors to your background color */
background: -webkit-gradient(linear, left top, left center, from(rgba(255,255,255,0)), to(rgb(255,255,255)));
background: -moz-linear-gradient(top, rgba(255,255,255,0), rgb(255,255,255));
background: linear-gradient(top, rgba(255,255,255,0), rgb(255,255,255));
/* I left out the `filter` property, because IE doesn't know `:before` and `:after` pseudo-elements anyway */
content: ' ';
height: 1em;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment