Created
October 18, 2012 17:52
-
-
Save interactivellama/3913720 to your computer and use it in GitHub Desktop.
Sprite Fade on Hover (Less CSS mixin)
This file contains 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
/* For Less CSS image replacement fade on hover transition with SPAN tag. | |
This uses the Helpless Less library for opacity and transition (#hl). | |
*/ | |
#llama { | |
.spriteHoverFade(@width: 10px, @height: 10px, @imageURL: '', @offsetX: 0px, @offsetY: 0px, @hoverOffsetX: 50px, @hoverOffsetY: 50px) { | |
display: inline-block; | |
position: relative; | |
text-indent: -9999px; | |
width: @width; | |
height: @height; | |
background-image: url("@{imageURL}"); | |
background-position: ~"@{offsetX}" ~"@{offsetY}"; | |
background-repeat: no-repeat; | |
span { | |
position: absolute; | |
top: 0; | |
left: 0; | |
bottom: 0; | |
right: 0; | |
background-image: url("@{imageURL}"); | |
background-position: ~"@{hoverOffsetX}" ~"@{hoverOffsetY}"; | |
#hl.opacity(0); | |
#hl.transition(opacity, 0.5s, ease); | |
} | |
&:hover span { | |
#hl.opacity(1); | |
} | |
} | |
} | |
/* Usage */ | |
.arrow { | |
#llama.spriteHoverFade(50px, 50px, '../img/sprites.png', '0px', '0px', '-50px', '0px'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment