How to Design a Unique Portfolio with css3 image effect


Design a Unique Portfolio with CSS3 Image Effects.

CSS has evolved into a diverse design medium over the last few years, allowing us to create a myriad of hip and elegant effects that were once limited to graphic design. When paired with jQuery, CSS3 can do some truly amazing stuff.

This tutorial will teach you how to take the awesome HTML5 Fluid Squares blueprint and transform it into a cool and responsive portfolio using some modern CSS tricks.

Here is a preview of the layout you will be creating.

View Demo

STEP 1

Download fluid squares and unpack its contents into a uniquely named project folder. Launch your HTML editor and open the” index.html” and “screen.css,” which is located in the “css” folder.
Take a look at the header and footer of the index.html to gain an understanding of what you may need to add to your own website templates if you plan to integrate the portfolio into an existing layout. The essential pieces are:

1
<meta name = "viewport" content="width=device-width, maximum-scale=1">

This tag controls how the page will scale when viewed on different screen sizes and goes at the top of the HTML head.

1
<script src="scripts/css3-mediaqueries.js"></script>

This line pulls in the JavaScript plugin that allows your CSS3 media queries to function across all browser platforms.
Additionally, you will need jQuery included in your header or footer, and may already be using it on your website. For the purpose of this tutorial, I have added it just above the

1
</head>

tag, using the Google library.

1
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>

STEP 2

Check out how the example DIVs are formatted. Pretty simple, right? Each one is placed inside the link tags and contains basic markup, text formatting and minimal use of classes.
At a maximum, four image columns will be displayed, which will shrink dynamically to three and then to two on mobile devices. Since we are building a portfolio layout, normally all we need to do is insert a DIV containing the images, but because we want to style our thumbnails using some interesting effects, we will be adding a specially styled span using Darcy Clarke’s background image hack. Add her code just above your document’s tag:


This code will detect your images and apply the image as a background of a span using the “image-srap” class to allow us to manipulate the image appearance with CSS.

STEP 3

Prepare your portfolio image thumbnails and place them into the “img” folder. For best results, crop them to 240×240 pixels.
Replace the contents of your document with your skeleton containers. Be careful not to remove the script in the document footer. For this demo, I am including 10 using the following:

1
2
3
4
5
<a href="#" target="_">
<div>
<img src="" alt="" />
</div>
</a>

Go ahead and update each “img” tag with the path to your images. We will come back to the links later on. All you need is the path and alt text and the CSS will handle the rest.

STEP 4

This is the fun part where we add some effects to our elements. The first style will be applied to the DIV. The second, “image-wrap,” is already defined for us by the JavaScript and is used to style the span.
Switch over to the” screen.css” document and find line 67. This is where you can begin editing. Add the DIV style first. I have called mine “lovely” but you can use any class name you like. This class is used primarily to style the text elements within the DIV:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
.lovely{
color: #fff;
font-size: .9em;
text-align: center;
font-style: italic; 
}
Now add two styles for the "image-wrap" class, one for the normal state and one for a hover.
.lovely .image-wrap {
-moz-transition: all 1s ease 0s;
 border-radius: 30em 30em 30em 30em;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2), 0 4px 5px rgba(0, 0, 0, 0.6) inset, 0 1px 0 rgba(0, 0, 0, 0.6) inset;
}
.lovely .image-wrap:hover {
 border-radius: 60em 60em 60em 60em;
box-shadow: 0 0 20px rgba(255, 255, 255, 0.6), 0 0 20px #FFFFFF inset;
}
The "border-radius" property is what allows you to create a circle. To ensure that it is rendered properly in most browsers, add some fallback declarations to each class like so:
-moz-border-radius: 30em 30em 30em 30em;
-khtml-border-radius: 30em 30em 30em 30em;
-webkit-border-radius: 30em 30em 30em 30em;

To get the stylish shadow effect, we are using the box-shadow property with an “inset” value. We reverse the color to white with a “0.6″ opacity for the hover to produce a pretty glow. If your portfolio background is something other than white, you can adjust the hover shadow color to match for a nice fading effect.

STEP 5

A portfolio is not complete without a short description of each work. Return to your HTML document and add a new DIV container below each image to hold your description text. To keep things semantic, give it a class of “description.” Wrap the text in a paragraph tag and give it a class of “description-text.”

1
2
3
4
5
6
7
8
9
10
11
<a href="#" target="_">
<div class="lovely">
  <!-- portfolio thumb -->  
  <img src="img/image.jpg" alt="Portfolio 1" />
    <!-- description overlay -->  
    <div class='description'>  
        <!-- description content -->  
        <p class='description-text'>Enter a description here</p>
    </div>  
</div>
</a>

Add the styles for these new classes to your stylesheet:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
.description{  
    top:40%; 
   width: 100%;
    display:none; /* hide it */  
    position:absolute;  
  border-radius: 20px 20px 20px 20px;
-moz-border-radius: 20px 20px 20px 20px;
    -khtml-border-radius: 20px 20px 20px 20px;
    -webkit-border-radius: 20px 20px 20px 20px;
    background-color:black;    
    color:white;  
    opacity:0.6; /* transparency */  
    filter:alpha(opacity=60); /* IE transparency */  
}  
p.description-text{  
    padding:10px;  
    margin:0;  
}

The absolute position allows you to place the description over the image with the “top” property. I am using percentages here to keep things scaling nicely. To get this element to only appear when the mouse hovers over the image element, you need to include another chunk of jQuery above your tag:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<script>
$(window).load(function(){  
    $('.description').each(function(){  
        $(this).css('opacity', 0);  
        $(this).css('width', $(this).siblings('img').width());  
        $(this).parent().css('width', $(this).siblings('img').width());  
        $(this).css('display', 'block');  
    });  
 
    $('.lovely').hover(function(){  
        $(this).children('.description').stop().fadeTo(500, 0.7);  
    },function(){  
        $(this).children('.description').stop().fadeTo(500, 0);  
    });  
}); 
</script>

If you are using a class name for the main DIV other than “lovely,” you will need to change it in the above script.

STEP 6

Top off your portfolio by adding a lightbox or image-preview plugin. If you are already using one, you should only need to edit your link tags to include the correct class, URL syntax or “rel” value. You may also wish to edit or replace the default styles included in the Fluid Squares stylesheet to add your own fonts, background colors and so on. The extras that come with Fluid Squares such as the “apple touch” icons may be customized and added to your site if you don’t have one already.

CONCLUSION

As you’ve learned, you can do some pretty cool stuff with CSS3 and jQuery to manipulate how images and content boxes appear and behave for unique and interesting effects. Experiment with other styles to give your portfolio its own twist!

View Demo

 

Author bio
Vail from DesignArticleWriters.com is a designer and tech blogger who enjoys writing everything and anything about design and tech. She love to recommend people who provide awesome stock photos to design community around the globe.

Recently Published

»

Importance and actions of cloud computing in e-commerce business

The e-commerce industry is growing in leaps and bounds, and, ...

»

How to remove Options from One Select Box and retain One Option?

One can easily remove  options of a select box from HTML and append ...

»

How to Ensure that Users Do Not Deactivate The Critical WordPress Plugins

It’s no secret that among all the remarkably useful features of ...

»

How to scroll to the top of a webpage using jQuery ?

If you are looking for an extraordinary method of smoothly scrolling ...

»

11 sources to gain perfect knowledge of html5 semantic tags

1. Html5tuts Html5tuts is a site dedicated to HTML5. Feel free to ...

»

How to move an element into another parent element using jQuery?

An important piece to the puzzle when coding with jQuery is that how ...

»

10 optionally Good WordPress Typography Plugins You could Opt For

It is not necessary that the person will follow the standard guide ...

»

8 creative 3d slider wordpress themes to keep your blog active

1. Display Display is a WordPress Theme best used for Portfolio and ...

»

11 quick remote screen sharing apps worth trying

1. Join Me Easy to start, easy to join, easy to manage, join.me takes ...