Category: CSS3

An awesome animated responsive grid in a few lines of javascript and css3 goodness

Screen Shot 2013-08-15 at 4.36.33 AM

Responsive grid is a pain to many people, because sometime they have to achieve the desired effects either using complex plugins, css layout styling with the help of media queries. And here comes a nifty solution which works perfectly well in all devices. The responsiveness is done using a few lines of Javascript which listens to window resize event. But to save the browser from refreshing the layout, it uses debounce technique which only fires after the resizing is done.

The trick is pretty neat. All you got to do is tell it a minimum width of the grid items. Then, once resized, it divides the window width by that minimum, extract the integer part and displays that many items in a row by setting a width (in percentage) for each of them.

[sourcecode language=”javascript”]
var minWidth = 250;
$(document).ready(function(){
$(window).resize($.debounce(250,function(){
var w = $(window).width();
var numberOfItems = parseInt(w/minWidth);
var itemWidthinPercentage = 100/numberOfItems;
$(".grid ul li").css({width:itemWidthinPercentage+"%"});
}));
});
[/sourcecode]

See the working grid at http://hasinhayder.github.io/responsivegrid and resize the window to check out how it fits perfectly.

The animation is done using the following css3 transition for each list item
[sourcecode language=”css”]
-webkit-transition:all 0.2s ease;
-moz-transition:all 0.2s ease;
-o-transition:all 0.2s ease;
-ms-transition:all 0.2s ease;
transition:all 0.2s ease;
[/sourcecode]

Checkout the demo and fork the github repo to customize it anyway you’d like to 🙂

CSS3 Storyline Animation using jQuery Transit Library

I have been learning CSS3 animations and transitions for last few days, and I found this awesome jQuery library “Transit” which can be used to replace CSS3 @KeyFrame animations. I am not a big fan of KeyFrame animations because it’s tough to write and you need to calculate a lot of things and express them in percentage of total time. Which makes it even harder to write. I mean for something small, it is more than awesome – but as soon you start writing something big, where each elements are chained to each other, you will find it pretty tough.

So, here goes the CSS3 Storyline Animation using jQuery Transit library. There are many sliders in the market who uses animations like this – so if you are good, you can even make a animation designer app using Transit.

Screen Shot 2013-07-23 at 9.01.23 PM

Github URL: https://github.com/hasinhayder/CSS3-Storyline-Animation

Live Demo: http://bit.ly/CSS3Storyline