• RSS
  • Facebook
  • Twitter
Comments


Photoshop Design
Created by Martin Angelov on Feb 16th, 2010
Web development is an area in which you have to keep up with the latest technologies and techniques, so that you are at the top of your game.  And no wonder – this is an area which changes with an amazing pace. What is the standard now will be obsolete in just a couple of years.
But changes do not come from nowhere. The early adopters are already using what we are going to use day-to-day a few years from now. One of these technologies is HTML5 – the new version of the fundamental language of the web.
Today we are making a HTML5 web template, using some of the new features brought by CSS3 and jQuery, with the scrollTo plug-in. As HTML5 is still a work in progress, you can optionally download a XHTML version of the template here.

Step 1 – The Design

Every design process starts with an initial idea which you later build upon. At this stage, designers usually go with programs such as Photoshop, to work on the details and see how it will all fit together.
Photoshop Design
Photoshop Design
After this, the design is hand coded with HTML and CSS going hand by hand, moving from designing the background, colors and fonts, to detail work on the content section.

Step 2 – HTML

It is a good time to note, that HTML5 is still a work in progress. It will remain so probably till around 2022 (I am absolutely serious about this). However some parts of the standard are complete, and can be used today.
In this tutorial, we are using a few of the tags introduced with this new version of HTML:
  • header – wraps your page header;
  • footer – wraps your page footer;
  • section – groups content into sections (e.g. main area, sidebar etc);
  • article – separates the individual articles from the rest of the page;
  • nav – contains your navigation menu;
  • figure – usually contains an image used as an illustration for your article.
These are used exactly as you would use normal divs. With the difference being that these tags organize your page semantically. In other words, you can present your content in such a way, that the subject matter of your page can be more easily determined. As a result services, such as search engines, will bring you more targeted visitors and thus boost your revenue (and theirs actually).
However, there are some implications in using HTML5 today. One of the most notable is the IE family of browsers, which does not support these tags (it can be fixed with a simple JavaScript include file though). This is why you should base your decision for moving to HTML5 on your site’s audience. And just for this purpose, we are releasing a pure XHTML version of this template as well.

template.html – Head section

01
02 
03<html>
04<head>
05 
06    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
07 
08    <title>Coding A CSS3 & HTML5 One Page Template | Tutorialzine demotitle>
09 
10    <link rel="stylesheet" type="text/css" href="styles.css" />
11 
12    
13 
14    
26 
27head>
You can notice the new at line one, which tells the browser that the page is created with the HTML5 standard. It is also much shorter and easier to remember than older doctypes. After specifying the encoding of the document and the title, we move on to including a special JS file that will enable Internet Explorer (any version) to render HTML5 tags properly. Again, this means that if a visitor is using IE and has JavaScript disabled, the page is going to show all messed up. This is why, depending on your audience, you should consider the regular XHTML version of this template, which works in any browser and is released free for all of our readers here.

template.html – Body Section

01<body>
02 
03    <section id="page">
04 
05    <header>
06 
07        <h1>Your Logoh1>
08 
09        <h3>and a fancy sloganh3>
10 
11        <nav class="clear">
12 
13            <ul>
14 
15                <li><a href="#article1">Photoshoota>li>
16                <li><a href="#article2">Sweet Tabsa>li>
17                <li><a href="#article3">Navigation Menua>li>
18 
19            ul>
20 
21        nav>
22 
23    header>
Here we use the new section tags, which divide your page into separate semantic sections. Outermost is the #page section which is set to a width of 960px in the style sheet (a fairly standard width with older computer displays in mind). After this comes the header tag and the navigation tag. Notice the href attributes of the links – the part after the hash symbol # corresponds to the ID of the article we want to scroll to.

template.html – Article

01
02 
03<div class="line">div
04 
05<article id="article1">
06 
07    <h2>Photoshoot Effecth2>
08 
09    <div class="line">div>
10 
11    <div class="articleBody clear">
12 
13        <figure>
14 
15            <a href="http://tutorialzine.com/2010/02/photo-shoot-css-jquery/">
16                <img src="http://tutorialzine.com/img/featured/641.jpg" width="620" height="340" />a>
17 
18        figure>
19 
20        <p>In this tutorial, we are creating a photo shoot effect with our just-released PhotoShoot jQuery plug-in. With it you can convert a regular div on the page into a photo shooting stage simulating a camera-like feel.p>
21 
22        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer luctus quam quis .... p>
23 
24    div>
25 
26article>
27 
28
The markup above is shared between all of the articles. First is the dividing line (the best solution semantically would be an
line, which in HTML5 has the added role of a logical dividing element, but unfortunately it is impossible to style in a cross-browser fashion, so we will stick with a DIV). After this we have the new article tag, with an unique ID, which is used by the navigation to scroll the page. Inside we have the title of the article, two paragraphs and the new figure tag, which marks the use of images in the article.

template.html – Footer

01        <footer>
02 
03            <div class="line">div>
04 
05            <p>Copyright 2010 - YourSite.comp>
06            <a href="#" class="up">Go UPa>
07            <a href="http://tutorialzine.com/" class="by">Template by Tutorialzinea>
08 
09        footer>
10 
11    section>
12 
13    
14 
16    <script src="jquery.scrollTo-1.4.2/jquery.scrollTo-min.js">script>
17    <script src="script.js">script>
18 
19    body>
20 
21html>
Lastly, we have the footer tag, which does exactly what you expect it to do. At the bottom of the page are the rest of the JavaScript  includes, which add the jQuery library and the scrollTo plug-in, which we are going to use in the next steps.
HTML5 CSS3 Website Template
An HTML5 & CSS3 Website Template

Step 3 – CSS

As we are using HTML5, we have to take some extra measures with the styling. The tags that this new version of HTML introduces, are not yet provided with a default styling. This is however easily fixed with a couple of lines of CSS code and the page works and looks as it is supposed to:

styles.css – Part 1

01header,footer,
02article,section,
03hgroup,nav,
04figure{
05    /* Giving a display value to the HTML5 rendered elements: */
06    display:block;
07}
08 
09article .line{
10    /* The dividing line inside of the article is darker: */
11    background-color:#15242a;
12    border-bottom-color:#204656;
13    margin:1.3em 0;
14}
15 
16footer .line{
17    margin:2em 0;
18}
19 
20nav{
21    background:url(img/gradient_light.jpg) repeat-x 50% 50% #f8f8f8;
22    padding:0 5px;
23    position:absolute;
24    right:0;
25    top:4em;
26 
27    border:1px solid #FCFCFC;
28 
29    -moz-box-shadow:0 1px 1px #333333;
30    -webkit-box-shadow:0 1px 1px #333333;
31    box-shadow:0 1px 1px #333333;
32}
33 
34nav ul li{
35    display:inline;
36}
37 
38nav ul li a,
39nav ul li a:visited{
40    color:#565656;
41    display:block;
42    float:left;
43    font-size:1.25em;
44    font-weight:bold;
45    margin:5px 2px;
46    padding:7px 10px 4px;
47    text-shadow:0 1px 1px white;
48    text-transform:uppercase;
49}
50 
51nav ul li a:hover{
52    text-decoration:none;
53    background-color:#f0f0f0;
54}
55 
56nav, article, nav ul li a,figure{
57    /* Applying CSS3 rounded corners: */
58    -moz-border-radius:10px;
59    -webkit-border-radius:10px;
60    border-radius:10px;
61}
We basically need to set the display value of the new tags to block, as you can see from the first couple of lines. After this we can style them as we would do with regular divs. We style the horizontal lines, the articles, and the navigation buttons, with the latter organized as an unordered list inside of the nav tag. At the bottom we assign the border-radius property for four different types of elements of once, which saves a lot of code.

styles.css – Part 2

01/* Article styles: */
02 
03#page{
04    width:960px;
05    margin:0 auto;
06    position:relative;
07}
08 
09article{
10    background-color:#213E4A;
11    margin:3em 0;
12    padding:20px;
13 
14    text-shadow:0 2px 0 black;
15}
16 
17figure{
18    border:3px solid #142830;
19    float:right;
20    height:300px;
21    margin-left:15px;
22    overflow:hidden;
23    width:500px;
24}
25 
26figure:hover{
27    -moz-box-shadow:0 0 2px #4D7788;
28    -webkit-box-shadow:0 0 2px #4D7788;
29    box-shadow:0 0 2px #4D7788;
30}
31 
32figure img{
33    margin-left:-60px;
34}
35 
36/* Footer styling: */
37 
38footer{
39    margin-bottom:30px;
40    text-align:center;
41    font-size:0.825em;
42}
43 
44footer p{
45    margin-bottom:-2.5em;
46    position:relative;
47}
48 
49footer a,footer a:visited{
50    color:#cccccc;
51    background-color:#213e4a;
52    display:block;
53    padding:2px 4px;
54    z-index:100;
55    position:relative;
56}
57 
58footer a:hover{
59    text-decoration:none;
60    background-color:#142830;
61}
62 
63footer a.by{
64    float:left;
65 
66}
67 
68footer a.up{
69    float:right;
70}
In the second part of the code, we apply more detailed styling to the elements. A width for the page section, a hover property for the figure tag and styles for the links inside of the footer. There are also a few styles that are not included here, but you can see them in styles.css. Now lets continue with the next step.
Structure Of The Page
Structure Of The Page - HTML5 Tags

Step 4 – jQuery

To enhance the template, we will create a smooth scrolling effect once a navigation link has been clicked, using the scrollTo jQuery plug-in that we included in the page earlier. To make it work we just need to loop through the links in the navigation bar (and the UP link in the footer) and assign an onclick event which will trigger the $.srollTo() function, which is defined by the plug-in.

script.js

01$(document).ready(function(){
02    /* This code is executed after the DOM has been completely loaded */
03 
04    $('nav a,footer a.up').click(function(e){
05 
06        // If a link has been clicked, scroll the page to the link's hash target:
07 
08        $.scrollTo( this.hash || 0, 1500);
09        e.preventDefault();
10    });
11 
12});
With this our template is complete!

Wrapping it up

In this tutorial, we leveraged the new semantic features provided by HTML5, to design and code a one-page web template. You can use it for free both personally and commercially, providing you leave the back link intact. If you like this tutorial, be sure to check out our twitter stream as well, where we share the latest and greatest design and development links.


Postado por Fernando Schimit - Fox Creative
[...]

Categories: , ,
Comments


Created by Martin Angelov on Mar 9th, 2010
Mosaic Slideshow
 
When designing a product page, it is often necessary to present a number of images in a succession, also known as a slideshow. With the raise of the jQuery library and its numerous plugins, there is an abundance of ready-made solutions which address this problem. However, to make a lasting impression to your visitors, you need to present them with something they have not seen before.
Today we are making a jQuery & CSS mosaic gallery. Mosaic, because it will feature an interesting tile transition effect when moving from one slide to another.

Step 1 – XHTML

The mosaic effect of the slideshow is achieved by dividing the original image into smaller parts. These tiles, which contain parts of the image, are sequentially hidden from view, which causes the effect. The markup of the slideshow is pretty straightforward. It consists of the main slideshow container element (#mosaic-slideshow), a left and right arrow for previous and next transition and the mosaic-slide div, which is inserted by jQuery at run-time.

demo.html

01<div id="mosaic-slideshow">
02    <div class="arrow left">div>
03    <div class="arrow right">div>
04 
05    <div class="mosaic-slide" style="z-index: 10;">
06 
07        
08        <div class="tile" style="...">div>
09        <div class="tile" style="...">div>
10        <div class="tile" style="...">div>
11        <div class="tile" style="...">div>
12 
13    div>
14div>
The div with the mosaic-slide class name is added to the page by jQuery after the transition() JavaScript function is executed (we will come back to this in the third step). Inside it you can see the tile divs. There are a total of 56 such divs, each of which has a 60px by 60px portion of the slide image set as its background.
Mosaic Slideshow
Mosaic Slideshow

Step 2 – CSS

To make this effect work (and most importantly look good), we have to add a few lines of CSS. Only the code directly used by the gallery is shown here. You can see the code that styles the rest of the demonstration page in styles.css.

styles.css – Part 1

01#mosaic-slideshow{
02    /* The slideshow container div */
03    height:500px;
04    margin:0 auto;
05    position:relative;
06    width:670px;
07}
08 
09.mosaic-slide{
10    /* This class is shared between all the slides */
11    left:80px;
12    position:absolute;
13    top:25px;
14 
15    border:10px solid #555;
16 
17    /* CSS3 rounded corners */
18    -moz-border-radius:20px;
19    -webkit-border-radius:20px;
20    border-radius:20px;
21}
22 
23.tile{
24    /* The individual tiles */
25    height:60px;
26    width:60px;
27    float:left;
28    border:1px solid #555;
29    border-width:0 1px 1px 0;
30    background-color:#555;
31}
The slideshow is contained inside the div with an ID of mosaic-slideshow (or #mosaic-slideshow, if we refer to it in a form of a CSS / jQuery selector).  There can be only one such div in the page, hence the use of an ID attribute.
However there can be more than one mosaic-slide divs in the page. The effect itself is achieved by stacking two slides on top of each other and hiding the tiles of the first one to reveal the ones of the second. This is why we are using a class name instead of an ID.
Some of the more interesting rules presented here are the three CSS3 rules for rounded corners. As the CSS3 standard is still a work in progress, browsers don’t support the regular border-radius property yet (except for the new 10.50 version of Opera), and need vendor-specific prefixes to recognize it. The -moz- prefix is used by Firefox, and -webkit- is used by Safari and Chrome.

styles.css – Part 2

01.arrow{
02    /* The prev/next arrows */
03    width:35px;
04    height:70px;
05    background:url("img/arrows.png") no-repeat;
06    position:absolute;
07    cursor:pointer;
08    top:50%;
09    margin-top:-35px;
10}
11 
12.arrow.left{
13    left:15px;
14    background-position:center top;
15}
16 
17.arrow.left:hover{
18    background-position:center -70px;
19}
20 
21.arrow.right{
22    right:15px;
23    background-position:center -140px;
24}
25 
26.arrow.right:hover{
27    background-position:center -210px;
28}
29 
30.clear{
31    /* This class clears the floats */
32    clear:both;
33}
The arrow class is shared by the previous and next arrows. They do need individual styling in addition to this common rule, so we add it after this. We are also using a CSS sprite as the background for the arrow divs. It contains a regular and hover state for both arrows, which spares us from having to use four individual images.
CSS spriting” is a widespread technique used by web designers. It allows the designer to join multiple smaller images into a single larger one, called a sprite, which is downloaded faster and saves the web server from multiple download requests. After this, the designer can use the CSS background property in conjunction with setting the elements to a fixed size, to show only the part of the sprite image that they need.
Mosaic Slideshow
Mosaic Slideshow

Step 3 – jQuery

After including the jQuery library to the page, we can move on to creating the script that will make the slideshow tick. To achieve the mosaic effect, the script defines 4 functions:
  • transition() – this function makes an animated transition between the currently shown slide, and a new one specified by the id parameter. It works by positioning the new slide we want to show, below the current one, and then hiding the current one one tile at a time;
  • generateGrid() – this function is used by transition() to generate a grid of tiles. Each tile contains a part of the slide image as its background;
  • next() – detects which the next slide is and runs the transition() function with its index;
  • prev() – analogous to next().

script.js – Part 1

01/* The slide images are contained in the slides array. */
02var slides = new Array('img/slide_1.jpg',
03                       'img/slide_2.jpg',
04                       'img/slide_3.jpg',
05                       'img/slide_4.jpg',
06                       'img/slide_5.jpg');
07 
08$(document).ready(function(){
09    /* This code is executed after the DOM has been completely loaded */
10 
11    $('.arrow.left').click(function(){
12        prev();
13 
14        /* Clearing the autoadvance if we click one of the arrows */
15        clearInterval(auto);
16    });
17 
18    $('.arrow.right').click(function(){
19        next();
20        clearInterval(auto);
21    });
22 
23    /* Preloading all the slide images: */
24 
25    for(var i=0;i
26    {
27        (new Image()).src=slides[i];
28    }
29 
30    /* Showing the first one on page load: */
31    transition(1);
32 
33    /* Setting auto-advance every 10 seconds */
34 
35    var auto;
36 
37    auto=setInterval(function(){
38        next();
39    },10*1000);
40});
The $(document).ready() method is executed once the page has finished loading. This will ensure that all the divs and other elements are accessible to the script. Inside it we bind a function for the click event on the previous and next arrows, preload all the images, show the first slide (otherwise the slideshow would be empty) and set up the auto-advance interval.

script.js – Part 2

01var current = {};
02function transition(id)
03{
04    /* This function shows the slide specified by the id. */
05 
06    if(!slides[id-1]) return false;
07 
08    if(current.id)
09    {
10        /* If the slide we want to show is currently shown: */
11        if(current.id == id) return false;
12 
13        /* Moving the current slide layer to the top: */
14        current.layer.css('z-index',10);
15 
16        /* Removing all other slide layers that are positioned below */
17        $('.mosaic-slide').not(current.layer).remove();
18    }
19 
20    /* Creating a new slide and filling it with generateGrid: */
21    var newLayer = $('
').html(generateGrid({rows:7,cols:8,image:slides[id-1]}));
22 
23    /* Moving it behind the current slide: */
24    newLayer.css('z-index',1);
25 
26    $('#mosaic-slideshow').append(newLayer);
27 
28    if(current.layer)
29    {
30        /* Hiding each tile of the current slide, exposing the new slide: */
31        $('.tile',current.layer).each(function(i){
32            var tile = $(this);
33            setTimeout(function(){
34                tile.css('visibility','hidden');
35            },i*10);
36        })
37    }
38 
39    /* Adding the current id and newLayer element to the current object: */
40    current.id = id;
41    current.layer = newLayer;
42}
The transition function uses the global current object to store the id of the currently shown slide, and a reference to the current slide div. This is later used to remove leftover slides and prevent a transition from occurring if the same slide as the currently active one is to be shown.
Notice how we use the each method on line 31 to loop through the tiles of the current slide and schedule them to be hidden in i*10 milliseconds in the future. As i is incremented for every tile, this mean that they are hidden 10 milliseconds apart from one another.
Slide Transition
Slide Transition

script.js – Part 3

01function next()
02{
03    if(current.id)
04    {
05        transition(current.id%slides.length+1);
06    }
07}
08 
09function prev()
10{
11    if(current.id)
12    {
13        transition((current.id+(slides.length-2))%slides.length+1);
14    }
15 
16}
17 
18/* Width and height of the tiles in pixels: */
19var tabwidth=60, tabheight=60;
20 
21function generateGrid(param)
22{
23    /* This function generates the tile grid, with each tile containing a part of the slide image */
24 
25    /* Creating an empty jQuery object: */
26    var elem = $([]),tmp;
27 
28    for(var i=0;i
29    {
30        for(var j=0;j
31        {
32            tmp = $('
', {
33                    "class":"tile",
34                    "css":{
35                        "background":'#555 url('+param.image+') no-repeat '+(-j*tabwidth)+'px '+(-i*tabheight)+'px'
36                    }
37            });
38 
39            /* Adding the tile to the jQuery object: */
40            elem = elem.add(tmp);
41        }
42 
43        /* Adding a clearing element at the end of each line. This will clearly divide the divs into rows: */
44        elem = elem.add('
');
45    }
46 
47    return elem;
48}
The parameter passed to generateGrid() is an object containing the rows and the columns we want to be generated, as well as the image to be set as the background of the tiles. While generating the tiles, the background image is offset according to the current position of the tile in the row and in the column. Finally the tile is added to an empty jQuery object which is returned at the end.
With this the mosaic slideshow is complete!

Wrapping it up

Today we created a slideshow with an animated mosaic transition effect. You can modify it to include a different number of rows and columns or change the way slides are changed entirely.


Postado por Fernando Schimit - Fox Creative
[...]