Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
If you've spent any amount of time on the Internet in the past few years, you've likely come across something very cool, called Masonry, though you probably had no idea that's what it was. Masonry is a jQuery plug-in that let's you create dynamically reorganized content on your site in a very nifty way. The best way to understand what Masonry does is to look at these two examples on the Masonry web site. It shows the content before and after applying Masonry. What's happening here is we have a page that has a bunch of items, so a regular index page, but we don't want to list them vertically like you would normally do; we want to list them horizontally.
The problem is some of the items are bigger than the others and as a result, they take up more space. If we use CSS to float these items left to right, what happens is the tallest item in each row defines the vertical height of that row and nothing can flow in to fill up that space. So what we end up with is a layout with a lot of dead space in between content. What Masonry does is it figures out where this content is and then finds elements that can fit into those places.
As a result, we get a more condensed layout, and it's also easier to cram more information in to a tighter space. The reason why you want to use Masonry is exactly that; you get to fit more content into a small space, and you also get to use more of the space on the page. As an added benefit, Masonry is responsive. So if we change the size of this window, you'll see that the content dynamically reorganizes to fit the new sized window.
This means simply by including Masonry in our index page, we automatically get a responsive index page that showcases as much content as possible in the currently available space. Masonry is being used both on responsive pages and on static pages, because of the way it handles layouts. What you see on the Masonry page is a fairly standard approach, but people use it for a lot of cool stuff. This is an example. It's an artist that uses Masonry of the front page to create this artistic representation of his own art.
As you can see, the items are still reorganizing in the same way, but because of what the items look like, it looks really neat. What we're going to do is take this regular static index page where each item is listed one below the other, and change it into dynamic Masonry page, like the one I've here on DESIGN IS PHILOSOPHY. All we're going to do is add the Masonry plug-in and hook it into our index page and then also activate some featured images on the index page.
When we do that, we get a response of layout that fits with the different screens, and because I made some very careful measurements, we will end up in a situation where the smallest screen--so the mobile phone--will have a beautifully laid out vertical stack of stories, just like what you see here. As a bonus, the front page will also have some front page widgets. So for example, this lynda ad that you see here at the top is actually a widget, and there's also two widgetized areas inside this layout that will activate as we move forward.
jQuery Masonry provides a whole new way of organizing index pages and allows us to put more content on index pages without sacrificing real estate in the process.
Get unlimited access to all courses for just $25/month.Become a member