Monday to Friday
10am to 6pm
Call us now on 02380 000567
 

WP Portfolio – An Easy CSS Grid Layout

One of the frequent questions that I get asked is how to create a grid layout for our WordPress Portfolio Plugin. It’s actually pretty simple, as you just need to use floats to shift the websites around. So to make things really easy, here’s a copy’n'paste example for doing a grid layout.

To see what we’re trying to achieve, this is a live example of the grid system working.

Grid Demo

A collection of websites for the grid demo.

BBC News
A popular destination for up-to-date news in the UK and around the World.
EnviroGadget
One of Dan's websites focusing on the best of eco-friendly gadgets.
Google
The search engine that most people use.
Smashing Magazine
One of the most interesting design-based websites on the web.
Wordpress
A slightly famous place to download a user-friendly content management tool for websites.
WP Doctors
Our very own website, where you can find info on our WordPress development services.

The portfolio shortcode and HTML

The HTML/shortcode you need to paste into a page or post to achieve the above layout is simply this:

<div id="portfolio-grid">
[wp-portfolio groups="1"]
<div class="footer">&nbsp;</div></div>

The portfolio shortcode and HTML

The CSS you need to give the grid layout (which can be pasted into the Template CSS section in Layout Settings in the plugin settings, or into your template’s styles.css) is below.

/* Grid Example */
#portfolio-grid .portfolio-website {
    width: 150px;
    float: left;
    height: 245px;
    border: 1px solid #BAD4E3;
    background: #E3EAF2;
    text-align: center;
    margin: 3px;
}
#portfolio-grid .website-description {
    text-align: left;
}
#portfolio-grid .website-name {
    font-size: 10pt;
}
#portfolio-grid .website-url {
    display: none;
}
#portfolio-grid .website-thumbnail {
    float: none;
    text-align: center;
    margin: 3px auto 10px;
}
#portfolio-grid .footer {
    clear: both;
}

The bits that make it work are the width of each portfolio item, the floating left, and the fixed height. All the other styles can be adjusted to suit your website.

Enjoy!
Dan

Written by Dan Harrison

Dan Harrison is the lead developer and director of WP Doctors Ltd, a web development agency specialising in writing bespoke tools for WordPress-based websites that save time, hassle and money.

Tags: , ,

3 Comments

Leave a comment
  1. Darren Singleton December 10, 2010 at 4:28 pm #

    Thanks for this Dan, this couldn’t have been posted at a better time. I have on my to-do list for the weekend to reinstall WP Portfolio on my main blog and I will certainly be using the grid layout!

    Thanks again,
    Darren

  2. Carol October 30, 2011 at 9:54 pm #

    This was a great help Dan. I’ve been doing all this by hand until now, while converting my website to WordPress I found your plugin. The grid layout makes the Portfolio more in tune with the look I wanted. Thanks so much! Carol

Leave a Reply