Create A Simple Responsive Portfolio Page with Filtering and Hover Effect (Updated)

Written by Kevin Liew on 29 Apr 2016
568,164 Views • Tutorials

Previously, I was showing how to create portfolio page with filtering and also hover effect for each of your project item. We achieved that effect with CSS3 and jQuery filter & sort plugin called MixItUp.

The response was pretty good, it has been in our popular post list for quite sometimes too. I guess it's due to the fact that filtering UI is quite a popular thing to implement. So, I was looking at the comment, I think I need to do an update and fix some of the issues.

Alright, this time it's not just fixing the issues but with some enhancements as well. Here's the updates:

  • MixItUp is now version 2.1.11, the one we used is way outdated. The good news is, the new one can load your desired filter on first run, not just showing all of it.
  • Easing plugin is removed and replaced with CSS3 transition instead. We can achieve the same thing with smaller file size and less JS. So, why not?
  • There're a couple of comments mentioned there's a bug that causing the whole thing moved 3-4px to the left. It's actually not an issue, because when you show ALL, the content became longer. Therefore, in IE you have a scrollbar displayed on the right which causing the undesired sudden movement that moves everything to the left. I didn't see this because I'm on Mac and scrollbar hover above the content instead of taking up the website viewport space.

I'm trying to keep everything the same so you can update it easily. This script will work pretty well with our previously published tutorial - display images with shape masking and nifty zoom effect.

Alright, lets get it started. First of all this is the screenshot of what we are about to build:

Based on the layout there are two main UI elements we need to build - Tab navigation for filtering and a grid of portfolio with hover effect. After that we will hook it up with MixItOut and our custom hover script.

HTML

First of all, we have the HTML markup for Tab navigation. It's a UL list with data filter. data-filter is included because MixItUp needs it for its filtering. It's updated to conform to the new MixItUp formatting. Classes are specified in data-filter to be consistent with jQuery filter()

<ul id="filters" class="clearfix">
<li><span class="filter active" data-filter=".app, .card, .icon, .logo, .web">All</span></li>
<li><span class="filter" data-filter=".app">App</span></li>
<li><span class="filter" data-filter=".card">Card</span></li>
<li><span class="filter" data-filter=".icon">Icon</span></li>
<li><span class="filter" data-filter=".logo">Logo</span></li>
<li><span class="filter" data-filter=".web">Web</span></li>
</ul>

Under the Tab navigation, we have portfolio list. We need to assign each portfolio a category in data-cat attribute. By matching data-filter with data-cat, this is how MixItUp filters portfolios.

Other than that, we added label and hide it by default. We will show it on mouse hover with CSS3.

<div id="portfoliolist">
  <div class="portfolio logo" data-cat="logo">
    <div class="portfolio-wrapper">
      <img data-src="img/portfolios/logo/5.jpg" alt="" />
      <div class="label">
        <div class="label-text">
          <a class="text-title">Bird Document</a> 
          <span class="text-category">Logo</span>
        </div>
        <div class="label-bg"> </div>
      </div>
    </div>
  </div>
.........
</div>

CSS

We divided CSS into two parts - general styling for UI elements and responsive.

html {
  overflow-y: scroll;
}

.container { 
	position: relative; 
	width: 960px; 
	margin: 0 auto; 
	-webkit-transition: all 1s ease;
  -moz-transition: all 1s ease;
  -o-transition: all 1s ease;
  transition: all 1s ease;	
}
 
#filters {
	margin:1%;
	padding:0;
	list-style:none;
}

	#filters li {
		float:left;
	}
	
	#filters li span {
		display: block;
		padding:5px 20px;		
		text-decoration:none;
		color:#666;
		cursor: pointer;
	}
	
	#filters li span.active {
		background: #e95a44;
		color:#fff;
	}
 

 
#portfoliolist .portfolio {
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	-o-box-sizing: border-box;
	width:23%;
	margin:1%;
	display:none;
	float:left;
	overflow:hidden;
}

	.portfolio-wrapper {
		overflow:hidden;
		position: relative !important;
		background: #666;
		cursor:pointer;
	}

	.portfolio img {
		max-width:100%;
		position: relative;
		top:0;
    -webkit-transition: all 600ms cubic-bezier(0.645, 0.045, 0.355, 1);
    transition:         all 600ms cubic-bezier(0.645, 0.045, 0.355, 1);		
	}
	
	.portfolio .label {
		position: absolute;
		width: 100%;
		height:40px;
		bottom:-40px;
    -webkit-transition: all 300ms cubic-bezier(0.645, 0.045, 0.355, 1);
    transition:         all 300ms cubic-bezier(0.645, 0.045, 0.355, 1);
	}

		.portfolio .label-bg {
			background: #e95a44;
			width: 100%;
			height:100%;
			position: absolute;
			top:0;
			left:0;
		}
	
		.portfolio .label-text {
			color:#fff;
			position: relative;
			z-index:500;
			padding:5px 8px;
		}
			
			.portfolio .text-category {
				display:block;
				font-size:9px;
			}
	
	.portfolio:hover .label {
    bottom:0;
  }
	.portfolio:hover img {
    top:-30px;
  }  

A simple responsive layout to make sure the grid display properly in different window dimension. Removed this bit if you have your own responsive grid system.

/* #Tablet (Portrait) */
@media only screen and (min-width: 768px) and (max-width: 959px) {
	.container {
		width: 768px; 
	}
}

/*  #Mobile (Portrait) - Note: Design for a width of 320px */
@media only screen and (max-width: 767px) {
	.container { 
		width: 95%; 
	}
	
	#portfoliolist .portfolio {
		width:48%;
		margin:1%;
	}		
}

/* #Mobile (Landscape) - Note: Design for a width of 480px */
@media only screen and (min-width: 480px) and (max-width: 767px) {
	.container {
		width: 70%;
	}
}

Javascript

Lastly, we have the Javascript. You can change its setting by visiting its documentation. They have updated it with a lot of explanation and samples. That's a pretty good job. You can check out the animation configuration to see what else effect can you achieve too.

$(function () {
		
	var filterList = {
	
		init: function () {
		
			// MixItUp plugin
			// http://mixitup.io
			$('#portfoliolist').mixItUp({
				selectors: {
  			  target: '.portfolio',
  			  filter: '.filter'	
  		  },
  		  load: {
    		  filter: '.app' // show app tab on first load
    		}     
			});								
		
		}

	};
	
	// Run the show!
	filterList.init();
	
});		

Conclusion

Nowadays, designers tend to cut down the clutters and keep everything simple. With this tutorial, we created a simple filtering portfolio page with hover effect. Sometimes we don't have to reinvent the wheel. With all sort of plugins available today, we can easily produce the effect we want by combining different javascript plugins.

Hopefully this update will solve a lot of questions you have. Drop a comment if you have any questions. Enjoy!

Demo Download
Join the discussion

Comments will be moderated and rel="nofollow" will be added to all links. You can wrap your coding with [code][/code] to make use of built-in syntax highlighter.

133 comments
tarun 11 years ago
i found a typo: "By match data-filter with date-cat" should read data-cat
Reply
Kevin Admin 11 years ago
Thanks for letting me know!
Reply
tinap 11 years ago
Thank you for this easy, simple tutorial. Am just building my portfolio and wanted to focus on what's important - the work!
Reply
isaiah 11 years ago
Ok so i downloaded this and it doesn't work
Reply
Vaib 10 years ago
First of all thanx for this script.
isaiah jut change

//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"

to

"http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"

it work's for me.
Reply
ove 10 years ago
thanx!! this did it
Reply
Luis 9 years ago
Thanks Very much...!! Vaib..... Now..this work
Reply
Jeremy D'Arcy 11 years ago
Great Tutorial!

I noticed that some of the names in your code need to be changed in order for it to work.
eg:
In the javascript functions:
#clientlist should be #portfoliolist
and .client should be .portfolio

I still haven't been able to get the hover function to work however... not sure why.

Here's what I'm using:

hoverEffect: function () {

// Simple parallax effect
$('#portfoliolist .portfolio').hover(
function () {
$(this).find('.label').stop().animate({bottom: 0}, 200, 'easeOutQuad');
$(this).find('img').stop().animate({top: -30}, 500, 'easeOutQuad');
},
function () {
$(this).find('.label').stop().animate({bottom: -40}, 200, 'easeInQuad');
$(this).find('img').stop().animate({top: 0}, 300, 'easeOutQuad');
}
);

}

Reply
kevin Admin 11 years ago
Thanks for the info! When I build it, it was clientList and change it in the end but forgot to update the article. :)
Reply
Jeremy D'Arcy 11 years ago
Ha, ok, figured it out. Building this from scratch before looking at the demo....

I was just missing the script for easing.


<script type="text/javascript" src="jquery.easing.min.js"></script>


now it works!

nice work. Thank you!
Reply
Hello 11 years ago
Hello,
how to enlarge image when click on it?

Thanks.
Reply
Kevin Admin 11 years ago
Do you mean a popup modal window to show large version of image? If that's the case you can look for a lightbox plugin and put them together.
Reply
Halee 10 years ago
I can't seem to get a lightbox to work with this, once I ad the script for the lightbox all of my images disappear???
Reply
Tim Kneipp 10 years ago
Hi Halee, I had the same problem with Lightbox, but after a some trial and error I found that removing this this script
<script src="js/jquery-1.10.2.min.js"></script>
will make everything fall into place.
Hope that helps.
Reply
Adrian Paun 10 years ago
Use prettyPhoto, it works great with this portfolio.
Reply
Brandon 9 years ago
I'm wanting to get this to work with prettyPhoto, but unable to get it to work. Would I need to combine the javascripts in some way? Any tips?
Reply
Ricky 11 years ago
Hi! Im brand new to this sort of thing and already stuck using the downloaded master files!

I unzipped the file and double clicked the index.html expecting it to work like the version online, however all that shows up is the names of the buttons, the All button is in orange and if you however over the rest the cursor does change, but nothing happens if you click.

Have i missed something stupid? Im aiming to use this as a basis and modify it to meet my needs!
Reply
Ricky 11 years ago
Hi, i posted a message earlier about the code not working offline, i found out that http: had to be added to the 15 line about ajax when working offline!

Just wondering if there was a way to adjust the code to make one picture go in to two categories? Say if it fitted under both Card and Logo.

Reply
Kevin Admin 11 years ago
Hi Ricky, apparently, based on MixItUp doc, you can do like this:


<div class="portfolio logo card" data-cat="logo">


I added card in the class, it will appear in both logo and card filter.
Reply
Ricky 11 years ago
Ha! I knew it would be something simple! It works great! Thanks!
Reply
Becs 11 years ago
Hi,

I just downloaded the demo, but the demo doesn't work.

None of the portfolio items appear.

When will this be fixed?

Thanks.
Reply
Kevin Admin 11 years ago
Hi Becs, Line 17 index.html, please add http: in front of the script src.
Reply
Dave 11 years ago
I am having issues with this when I try integrating it into ZURB's Foundation, most of the script is working but for some reason when I hover over the image to see the more information section that pops up (ie: Bird Photos, APP), the text does not appear, it is just a coloured box. Any ideas on how to fix this? Really love the way this application looks and works!
Reply
Eugene 10 years ago
Same problem. Help please.
Reply
Luke 11 years ago
Hi Kevin,

Great tutorial! Thanks for posting! :)

If I wanted to change the size of the thumbnails and number on each row, how would I go about doing this?

Really appreciate your help!

Thanks!
Reply
Kevin Admin 11 years ago
Hi Luke, you change it in CSS portfolio class.
Reply
sdk 11 years ago
would it be possible to place the filter navigation as wordpress custom menu items? So, instead of having the tab filters above the thumbs, the filters would act as submenu items?

eg.

About
Portfolio
-Water
-Fire
-Earth
-Air
Contact
Reply
Shashikant 11 years ago
Could you please tell me how can i add hover effect on tabs under <li> items.
Reply