How to Make a Threadless Style T-Shirt Gallery


How to Make a Threadless Style T-Shirt Gallery

The Basic Idea

Threadless is one of my absolute favorite t-shirt companies, so naturally I frequent their sites. One particular site (Type Tees) caught my eye with how they displayed shirts. Armed with jQuery, I went to work, while making some tweaks of my own.

Here’s the gist: There’s a thumbnail which is a full sized image in a container div, which is smaller than the full sized image. The image is centered within it, but doesn’t show entirely because overflow:hidden is turned on. When the mouse hovers over the thumbnail, overflow:hidden gets turned off, and the entire image is displayed.

Here's the gist

The caption and overlay are positioned on top of the thumbnail/image while all this is going on, disappearing when the full image is displayed from the mouse hovering on top of it. The caption is self explanatory, but the overlay in this tutorial is what rounds the bottom corners using a semi-transparent png.

Customizing It

Not everyone is looking to only display t-shirts with this method, it works equally well with standard images too. The overlay image should be the same size as your thumbnail – it serves to define the size of the link. You can use the overlay to create some neat effects, I did rounded corners, but you could do things like gradients or different corners. I’ve included the code required below, but really, you should probably just download the attached files as it’s easier to tweak from there.

The CSS

*{
 margin:0;
 padding:0;
 }
 img{
 border: none;
 }
 body {
 text-align: center;
 background: #222;
 }
 h2{
 color: #333;
 font:italic 36px Georgia, serif;
 padding: 20px;
 border-bottom: dashed 1px #999;
 clear: both;
 }
 #content{
 width: 100%;
 margin: 0px auto;
 background: #fff;
 text-align: center;
 margin-bottom: 50px;
 }
 .row{ /*Container for each row of shirts*/
 width: 495px;
 margin: 0px auto;
 clear:both;
 padding: 20px 0;
 }
 .teebox{
 overflow: hidden; /*Prevents excess of image from showing*/
 position: relative;
 margin: 0 10px;
 width: 144px; /*Width and height define thumbnail size*/
 height: 183px;
 float: left;
 clear: right;
 z-index: 0;
 }
 .selected{
 overflow: visible; /*Display part of image that not currently visible*/
 z-index: 10;
 }

 .teebox img {
 left:-84px; /*Use this to center your image when not hovered*/
 position: absolute;
 }
 .teebox a{ /*Area that changes to selected class when hovered over*/
 display:block;
 position: relative;
 float: left;
 left: 84px; /*Use to line up the overlay image*/
 z-index: 1;
 }
 .caption{
 color: #2FB5FF;
 font:14px Arial;
 position: relative;
 float: left;
 left: 0px;
 top: 146px;
 padding: 10px;
 background: #222;
 z-index: 1;
 }

The HTML

This is the HTML for a single shirt, but you could repeat the rows and shirt containers (.teebox) as needed.

<div id="content">
 <div class="row">
    <div class="teebox">
       <a href="#"><img src="overlay.png"/></a><img src="pinktee.png"/>
       <div class="caption">$10</div>
    </div>
 </div>
</div>

The jQuery

$(document).ready(function() {
 $(".teebox a").mouseover(function(){
    $(this).parent().addClass("selected");
    $(this).find('img').animate({opacity: "0.0"}, 0); //Hides overlay
    $(this).parent().find('.caption').hide(); //Hides Caption
 }).mouseout(function(){
    $(this).parent().removeClass("selected");
    $(this).find('img').animate({opacity: "1.0"}, 0); //Shows overlay
    $(this).parent().find('.caption').show(); //Shows Caption
 });
});

The Wrap Up

The primary differences between the Threadless version and my own are the jQuery and method of image hiding. My version was based on observing the frontend of their site, with some referencing of the code, which they appeared to use straight Javascript for. Additionally they made the image a background image, while I kept it as a normal img. Other than that, there are no glaring changes as far as I know.

If you’re in any way lost, check out the downloadable files, they help a bunch I swear. Any particularly pressing issues can be brought up in the comments. Keep in mind you may need to implement the PNG fix in order to make this widely compatible. Also, as a way of thanking Threadless for bringing up this wonderful idea, be sure to visit them.

  • Stumble It!
  • Bookmark It!
  • Tweet it!

About Sam Dunn

Sam is a designer and co-founder of One Mighty Roar from Massachusetts, USA. He takes particular interest in all things aesthetically pleasing. He can be found online at Vivalasam and Twitter.

 

Discussion

  1. BeyondRandom

    June 26th, 2009 at 10:16 PM

    Great tut! I have a shirt gallery site and I have been looking for a cool way to show off the shirts…will have to try this.
    .-= BeyondRandom´s last blog ..2012 (HD) Movie Trailer =-.

  2. Paul

    June 27th, 2009 at 12:20 AM

    Great tutorial.
    Nice job! Gotta love jQuery!

  3. Callum Chapman

    June 27th, 2009 at 4:17 AM

    That’s a real nice effect, love it!
    .-= Callum Chapman´s last blog ..BLOG.CALLUMCHAPMAN HAS MOVED! =-.

  4. 2tone

    June 27th, 2009 at 12:21 PM

    WOW! Very nice effect

  5. Music T-shirts

    June 28th, 2009 at 1:41 AM

    Thank you so much for this post. Really nice.

  6. sonichtml

    June 29th, 2009 at 6:04 AM

    nice effect…i live it..

  7. Aayush

    June 29th, 2009 at 10:25 PM

    great post….

  8. nox

    June 30th, 2009 at 12:01 PM

    i test in IE and safari but IE dont work :/

  9. Sam Dunn

    June 30th, 2009 at 12:16 PM

    @nox I have tested/made sure it works in Firefox, Safari, and IE 7

  10. Mladen

    July 1st, 2009 at 8:23 AM

    Lovely!! Great post!!

  11. thekanyon

    July 1st, 2009 at 2:21 PM

    Great Effect! It will work on IE7+. IE6 doesn’t support png transparency so you might need to use gif files for a similar effect.

  12. Max

    July 3rd, 2009 at 7:56 PM

    Problem with overlay in IE8. The overlay works fine but after mouseout the rounded corners leave a black outline. It’s not very noticeable in your demo, but I made a custom overlay and it is very noticeable, although both your overlay and my overlay work and looke fine in FF. Please let me know if there is a fix for IE8. Thanks!

  13. Tom

    July 5th, 2009 at 5:32 PM

    Hey great idea thanks for sharing this.

  14. elcodigodebarras

    July 9th, 2009 at 8:47 PM

    Thanks for this usefull resource; Long time ago I was looking for something like this, for my t shirts designs: http://www.deviantart.com/#order=9&q=elcodigodebarras+t+shirt
    .-= elcodigodebarras´s last blog ..CUT AND PASTE (Copiar y pegar) – Fuera del mundo virtual =-.

  15. ChattyShirts

    July 13th, 2009 at 2:45 PM

    Nice, thanks for sharing! This plus the GoMedia tutorial for photo realistic t-shirt mock-ups can work quite well. I also like that it uses jQuery, which makes it simpler and leaner to use with a WordPress blog.
    .-= ChattyShirts´s last blog ..Writable Thought Bubble =-.

  16. Bradford Sherrill

    August 4th, 2009 at 11:48 AM

    nice concept

  17. T-Shirt Printing

    August 8th, 2009 at 6:24 AM

    Thanks for the great tutorial – can imagine that many t-shirt web sites will start adopting this for a while

    Alex @indigo
    .-= T-Shirt Printing´s last blog ..London Calling =-.

  18. Liam

    August 24th, 2009 at 4:52 AM

    This does not require jQuery at all, could all be done with CSS.

  19. Sam Dunn

    August 24th, 2009 at 8:46 AM

    @Liam
    I am going for compatibility on this one, and the actual Threadless site makes use of Javascript to do this as well.

  20. Jared Roberts

    August 24th, 2009 at 1:23 PM

    Two Girls One Cup…. Really? LOL!

  21. Sander

    August 25th, 2009 at 4:45 AM

    @Sam Dunn

    I agree with Liam. Although the actual Threadless site uses Javascript, this could easily be done with some simple CSS. The only compatibility issue lies in the :hover at IE6. But even then a few lines of vanilla Javascript can fix that, there’s no need for a 100k jQuery solution.

    A quick mockup: http://office.react.nl/~sandervl/jquery-madness/
    .-= Sander´s last blog ..Licht aan het einde van de steeg, 22-08-2009 =-.

  22. Sander

    August 25th, 2009 at 5:28 AM

    My apologies; the link above is not accessible for the outside world. Please use http://home.react.nl/~sandervl/jquery-madness/ :)
    .-= Sander´s last blog ..Licht aan het einde van de steeg, 22-08-2009 =-.

  23. Sam Dunn

    August 25th, 2009 at 8:15 AM

    @Sander
    That is certainly a route that is becoming increasingly more doable and I am a big fan of pure CSS. I see that you have taken the inititiave to go ahead and make a page of the CSS solution, dedicated aren’t we?

    Personally I don’t view jQuery as a 100k solution as in many cases I am not loading it for the sake of doing one compatible :hover.

  24. jams

    August 25th, 2009 at 9:31 PM

    nice works guys…

  25. t shirt printing

    September 23rd, 2009 at 12:17 PM

    Wow! I have been seen a lot of t shirt sites but this is one is really cool. Will definitely give this a try.
    .-= t shirt printing´s last blog ..T Shirt Printing =-.

Join the Conversation!

Remember: Life's not all doom and gloom, so please keep it constructive. If we've made an error or missed something big, please let us know! Learning is revisions, after all.

CommentLuv is Enabled

 

Sponsors

Advertise on Build Internet!