Pure CSS3 Turnover Effect Animation of a Button Without Sprites
Ye ye I know that this is all but ‘real’ coding, but I want to grab the chance to post something here just because I’ve done some little css modifications to this blog.
Oh yes, I’m excited in particular about the ‘read on’ button animation and how easy is to achieve this without using sprites or images.
In short, here is where I want to go:
So, let’s see the html code of the button:
1 2 3 4 5 6 7 8 9 |
|
As you can see, there’s no real magic but a simple anchor (or link, whatever) a
inside a div
all wrapped in a footer
element.
The footer
will be our viewport, the div
will be the only element animated and it should translate top by the amount of his height as explained here:
So basically we need to have a fixed height and use a css transition to move the div up by his whole height.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
You can see that I’ve wrapped all inside a mixin
so I can easily use one-line of code to sett the different buttons height based on the viewport of the user’s browser.
1 2 3 4 5 6 7 8 9 |
|
With Compass I can use one of their mixin to super easily use CSS3 transitions, so all I need to do is simply add this code to get the animation effect:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
So these 25 lines of SCSS code make me puking rainbows just because they will be compiled to 60+ lines of CSS code and basically there’s why you should use Compass+SCSS or shoot yourself. PEACE!
Comments