Learn How To Convert A Beautiful Website from PSD To HTML5/CSS3
In the previous web design tutorial, i showed you a few techniques on how to design a clean & beautiful agency website from scratch using adobe phoroshop, this is second part two of the tutorial, in this part i will teach you how to convert the website we designed in the previous tutorial from PSD file to HTML5/CSS3 website, we are going to use javascript libraries to animate the slider and add awesome animation effects to the website sections.
Final Result :
Resources :
– Images by unsplash.com
– Raleway font
– Wow.js
– Animate.css
– Responsiveslides.js
– Logos by gertvanduinen.com
Setting up our Directories and Files :
The folders and files structure are very simple, in this step we will need one main/root folder called “Heros”, in which we will put all our files and folders. inside the “Heros” folder create the following sub-folders, “css” folder for css/styling files, “js” folder for javascript files, “img” folder for all the images we are going to use and the “fonts” folder, create a new text file inside the “Heros” main folder and rename it to “index.html”, all our HTML5 markup will be placed inside the “index.html”, the image below represent the files and folders structure that we just created.
Slicing the PSD file :
First, we need to slice the PSD elements as images, so we can use them later for the web, in our case we need to slice the logo, the slider images, the projects logos we need a gray version for the normal state and a white version of the hover state like the image below, we also need the clients logos and the social media icons in the footer section, it’s very easy to slice a psd element, let’s slice the logo as an example to show you the process of slicing an element.
Open the PSD template in photoshop, right click the logo group in the layers panel and select “Duplicate Group..” from the menu that appears.
A new window will pop up, change the Destination document to “New” and press “OK”.
Next we are going to remove the blank space around the logo, go to “Image > Trim..”.
A new window will appear, for the “base on” option select “Trasparent Pixels” and for “Trim Away” option check top, left, right and bottom check boxes, then press “OK”.
Finaly go to “File > Save as for Web & Devices..” or press “alt + shift + ctrl + s”, change the file type to “PNG-24” and make sure to check the “Transparency” check box as you can see in the image below, click save and save the image in the images folder “img” we created previously.
These are the steps to slice a PSD element, follow the same steps to slice the rest of the nedded elements.
Setting the Stylesheet/css files :
In this step we are going to create the three css files we will need in this tutorial, the “reset.css” file to reset the default css applied by the browser’s, the “animate.css” by Daniel Eden for the aimations we are going to add later to our website elements and the “main.css” file for all our custom css coding, let’s create these three files.
Begin by creating a new file inside the “css” folder we created previously , name it “reset.css”, open it in your favorite text editor, i personaly use sublime text, copy and paste the css code below into it and don’t forget to save it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video { margin:0; padding:0; border:0; outline:0; font-size:100%; vertical-align:baseline; background:transparent; } body { line-height:1; } img{ max-width: 100%; } article,aside,details,figcaption,figure, footer,header,hgroup,menu,nav,section { display:block; } nav ul { list-style:none; } blockquote, q { quotes:none; } blockquote:before, blockquote:after, q:before, q:after { content:''; content:none; } a { margin:0; padding:0; font-size:100%; vertical-align:baseline; background:transparent; color: #454545; } /* change colours to suit your needs */ ins { background-color:#ff9; color:#000; text-decoration:none; } /* change colours to suit your needs */ mark { background-color:#ff9; color:#000; font-style:italic; font-weight:bold; } del { text-decoration: line-through; } abbr[title], dfn[title] { border-bottom:1px dotted; cursor:help; } table { border-collapse:collapse; border-spacing:0; } /* change border colour to suit your needs */ hr { display:block; height:1px; border:0; border-top:1px solid #cccccc; margin:1em 0; padding:0; } input, select { vertical-align:middle; } |
Next download the “animate.css” from this link and place it in the css forlder, then create a new file name it “main.css” and place in the “css” folder as well.
Setting the Javascript files :
For the javascript files we are going to need four javascript libraries, download the following libraries and place them in the “js” folder we created previously, we will need the JQuery library(download the production version), the responsiveslides.js library to animate the slider, and the wow.js library by Matthieu Aussaguel, it’s used to reveal animations added by animate.css when you scroll down a web page.
Setting the Startup Markup :
Now open the “Index.html” we created previously in your text editor, and write the following html5 layout.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<!DOCTYPE html> <html lang="en"> <head> <!-- Title --> <title>Heors Agency</title> <!-- character encoding --> <meta charset="utf-8"> <!-- Stylesheet/CSS Files --> <link rel="stylesheet" type="text/css" href="css/reset.css"> <link rel="stylesheet" type="text/css" href="css/animate.css"> <link rel="stylesheet" type="text/css" href="css/main.css"> <!-- Javascript Files --> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/slider.js"></script> <script type="text/javascript" src="js/wow.js"></script> <script type="text/javascript" src="js/main.js"></script> </head> <body> </body> </html> |
As you can see we start with a simple HTML5 document, we declared the HTML5 doctype <!DOCTYPE html>, we added a title to the page using the “<title>” tag, we defined the character encoding using the <meta> tag and the charset attribute, we also linked the stylesheet/css and javascript files we created previously to our html document, the text between “<!–” and “–>” is a just a comment, it will not be displayed in the browser, i use it just to keep my code organised, please make sure to keep the same structure in the code above.
We need to link the fonts that we will use in our website, i will use the “raleway” font, you can download it from google fonts, or you can find it in the downloadable zip file in the begening of this tutorial, we will use the Regular, Bold and Semi-Bold fonts, now open the “main.css” file in your text editor and past in it the code below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
/* Fonts */ @font-face { font-family: 'raleway-regular'; src: url('../fonts/raleway-regular.eot'); src: url('../fonts/raleway-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/raleway-regular.woff') format('woff'), url('../fonts/raleway-regular.ttf') format('truetype'), url('../fonts/raleway-regular.svg#ralewayregular') format('svg'); font-weight: normal; font-style: normal; } @font-face { font-family: 'raleway-bold'; src: url('../fonts/raleway-bold.eot'); src: url('../fonts/raleway-bold.eot?#iefix') format('embedded-opentype'), url('../fonts/raleway-bold.woff') format('woff'), url('../fonts/raleway-bold.ttf') format('truetype'), url('../fonts/raleway-bold.svg#ralewaybold') format('svg'); font-weight: normal; font-style: normal; } @font-face { font-family: 'raleway-semibold'; src: url('../fonts/raleway-semibold.eot'); src: url('../fonts/raleway-semibold.eot?#iefix') format('embedded-opentype'), url('../fonts/raleway-semibold.woff') format('woff'), url('../fonts/raleway-semibold.ttf') format('truetype'), url('../fonts/raleway-semibold.svg#ralewaysemibold') format('svg'); font-weight: normal; font-style: normal; } |
Next we will add some general styling we will use along the way, copy and past the code below, in the “main.css” file, right below the fonts code we added in the step before.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
/* General CSS*/ h1, h2, h3, h4, h5 ,h6{ color: #6d6d6d; font-family: "raleway-regular", arial; letter-spacing: 1px; } h1 { font-size: 2em;} h2 { font-size: 1.5em;} h3 { font-size: 1.17em;} h5 { font-size: .83em;} h6 { font-size: .75em;} h1, h2, h3, h4, h5, h6 { font-weight: bolder } .clearfix:before, .clearfix:after { content: " "; display: table; } .clearfix:after { clear: both; } .clearfix { *zoom: 1; } |
In the css code above, we added some css styling for the heading tags(h1, h2, h3..), then we styled the “.clearfix” which we will use to clear the floated elements.
By looking at the PSD template, you will notice that the template is composed of seven sections, which are the header, the slider, the services section, the projects section, the clients section, the call to action section and the footer section, we well start by creating and styling the header section based on this composition.
Header :
html :
The header section is very simple, it consist of two element, the logo and the navigation menu, copy and the past the code below between the <body> and </body> tags.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<!-- header Section --> <header> <div class="container"> <!-- Logo --> <a href="#" class="logo"> <img src="img/logo.png" alt="Heros"/> </a> <!-- Navigation Menu --> <nav> <ul> <li><a href="#" class="selected">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Team</a></li> <li><a href="#">Journal</a></li> <li><a href="#">Contact</a></li> </ul> </nav> </div> </header><!-- end header --> |
In the HTML code above, we created the header section using the html 5 <header> tag, inside it we added a div with the class “container”, we will use the “container” class to center the layout with the browser window, the “container” div is wrapping the logo image using the <img> tag which is nested inside an anchor link <a>, right below the logo, we added the navigation menu using the html5 tag <nav> , which is wrapping an unordered list <ul> containing the navigation menu anchor links <a>, notice in the first navigation menu list item, we added the “selected” class to the anchor link <a>, we will use it later to style the current page state.
css :
We need to style the “container” class, copy and past the following code right below the fonts code we added before inside the “main.css” file.
1 2 3 4 |
.container{ width: 1100px; margin: 0 auto; } |
As discussed previously the “container” class is used to center the layout with the browser window, we applied to it a fixed width of 1100px, 0px for the top and bottom margin and auto for the left and right margin in order to center it.
Now let’s style the header section.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
/* header */ header{ width: 100%; height: 90px; background: #ffffff; position: relative; } header .logo{ margin-top: 30px; float: left; } header nav{ float: right; margin-top: 37px; } header nav ul li{ list-style: none; float: left; margin-left: 45px; } header nav ul li a{ text-decoration: none; color: #5e5d5d; font-family: "raleway-regular", arial; font-size: 14px; letter-spacing: .5px; transition:all .2s linear; -o-transition:all .2s linear; -moz-transition:all .2s linear; -webkit-transition:all .2s linear; } header nav ul li a:hover, header nav ul .selected{ color: #ff4242; } |
In the css code above, we started by styling the header “head”, by giving a 100% width it will take the full screen width, a fixed height, a white background color and we positioned it relatively to the browser window, then we floated the logo “.logo” to the left with a top margin of 30px to center it vertically with the header “head”, the same thing goes with the “nav” element, we floated the navigation menu “nav” to the right and gave it a top margin of 37px.
After that we moved to the unordered list items “li”, we removed the default list style, we floated the list “li” items to the left to put all the items side-by-side, we used a left margin to get space between each menu element, for the anchor links “a” inside the list items “li”, we applied some basic css styling to it, we removed the default underline style, we applied a dark gray “5e5d5d” color to the link text, set the “raleway-regular” as the font family, set a font size and added the transition css3 property to get a nice fade effect on the hover state, we added the vendor prefixes “-o-“, “-moz-” and “webkit” to ensure that the transition property is supported by the popular browsers like safari, google chrome, opera…, then we changed the text color of the element with the “selected” class, which is used to indicate the current page in the navigation menu, we also used the pseudo element “:hover” to change the text color of the navigation menu links from gray to red when the mouse cursor is over them.
Open the “index.html” file in your browser, you should see something similar to the image below.
Slider :
Now let’s move to the slider section, in this part we will use the responsiveslides.js library we downloaded previously, to animate the slider, we are going to start by the HTML layout first, then the css styling and finally the javascript code.
html :
Copy the code below and past right below the header html code we added in the previous step.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<!-- Slider Section --> <section class="slider_wrapper"> <div id="slides"> <div class="slide"> <img src="img/slide1.jpg" alt=""/> <h3>sed do eiusmod tempor incididunt.</h3> </div> <div class="slide"> <img src="img/slide2.jpg" alt=""/> <h3>officia deserunt mollit velit esse.</h3> </div> <div class="slide"> <img src="img/slide3.jpg" alt=""/> <h3>cillum dolore eu fugiat nulla pariatur.</h3> </div> </div> </section><!-- end slider --> |
We started by creating the slider section wrapper using the html5 <section> tag with the class “slider_wrapper”, then we added a div with the id “slides”(the id must be unique and never applied to an html element in the same page), which contains three div’s with the class “slide”, inside each “slide” div we added the slider images <img>(the images are 1700x670px), and the slider captions <h3> with the “caption” class.
css :
Now let’s add the css for to style the slider, at the end of this section you will find the complete css code for the slider section.
1 2 3 4 5 6 |
.slider_wrapper{ width: 100%; height: auto; position: relative; overflow: hidden; } |
First, we styled the slider section with the class “.slider_wrapper”, we want it to take the full width of the browser window, we set the height to auto, we positioned it relatively then we set the overflow property value to hidden, just to clear the floated elements inside it.
1 2 3 4 5 |
#slides .slide{ position: relative; width: 100%; float: left; } |
After that we positioned the slides with the class “.slide” relatively to the parent element “slider_wrapper” section, then we set the float property to get each slide side-by-side.
1 2 3 4 |
#slides .slide img{ width: 100%; height: auto; } |
Here we applied some css properties to the slider images “img”, to make sure the image take the full width of the screen we set the width to 100%.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#slides .slide .caption{ width: 100%; position: absolute; color: #5a5a5a; text-align: center; font-family: "raleway-bold", arial; font-size: 50px; font-weight: bold; text-transform: uppercase; line-height: 60px; top: 50%; -webkit-transform: translateY(-50%); -moz-transform: translateY(-50%); -o-transform: translateY(-50%); transform: translateY(-50%); } |
We then moved to the captions “.caption” style, we set the width to 100%, we centered it horizontally using the text-align property, we used a css trick to center the “.caption” element vertically, by setting the top property value to 50% and applying the translateY() function to the transform css3 property with a value of -50%.
Now we are going to style the slider pagination, the html markup for the pagination will be added automatically inside the “slider_wrapper” section, after we initialize the slider with javascript, the html markup will look like the html code below, it consist of an unordered list <ul> containing a list items <li> with nested anchor links </a>, each link have a number refereeing to each slide.
1 2 3 4 5 6 7 8 9 10 11 |
<ul class="rslides_tabs rslides1_tabs"> <li class="rslides1_s1 rslides_here"> <a href="#" class="rslides1_s1">1</a> </li> <li class="rslides1_s2"> <a href="#" class="rslides1_s2">2</a> </li> <li class="rslides1_s3"> <a href="#" class="rslides1_s3">3</a> </li> </ul> |
Now it’s time to style the slider pagination.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
.slider_wrapper .rslides_tabs{ width: 100%; position: absolute; text-align: center; bottom: 80px; z-index: 9999; } .slider_wrapper .rslides_tabs li{ list-style: none; display: inline; } .slider_wrapper .rslides_tabs li a{ display: inline-block; width: 12px; height: 12px; margin-left: 15px; background: rgba(255, 255, 255, .5); text-indent: -999px; overflow: hidden; -webkit-border-radius: 100px; -moz-border-radius: 100px; -o-border-radius: 100px; border-radius: 100px; } .slider_wrapper .rslides_tabs .rslides_here a{ background: rgba(255, 255, 255, 1); } |
We began by styling the unordered list “ul” element with the class “.rslides_tabs”, we absolutely positioned it, and we moved it 80px from the bottom, we set the display property to inline in order to place the list items “li” side-by-side, we also centered the anchor links inside it using the text-align property, then we applied some basic styling to the anchor links “a” inside the “li” elements, we used the test-indent property to get ride of the text numbers inside the anchor links.
The complete code for the slider section :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
/* slider */ .slider_wrapper{ width: 100%; height: auto; position: relative; overflow: hidden; } #slides .slide{ position: relative; width: 100%; float: left; } #slides .slide img{ width: 100%; height: auto; } #slides .slide .caption{ width: 100%; position: absolute; top: 50%; color: #5a5a5a; text-align: center; font-family: "raleway-bold", arial; font-size: 50px; font-weight: bold; text-transform: uppercase; line-height: 60px; -webkit-transform: translateY(-50%); -moz-transform: translateY(-50%); -o-transform: translateY(-50%); transform: translateY(-50%); } .slider_wrapper .rslides_tabs{ width: 100%; position: absolute; text-align: center; bottom: 80px; z-index: 9999; } .slider_wrapper .rslides_tabs li{ list-style: none; display: inline; } .slider_wrapper .rslides_tabs li a{ display: inline-block; width: 12px; height: 12px; margin-left: 15px; background: rgba(255, 255, 255, .5); text-indent: -999px; overflow: hidden; -webkit-border-radius: 100px; -moz-border-radius: 100px; -o-border-radius: 100px; border-radius: 100px; } .slider_wrapper .rslides_tabs .rslides_here a{ background: rgba(255, 255, 255, 1); } |
js :
Now open the “main.js” file inside the “js” folder, past the code below in it to initialize the slider, this code will animate the slider and will add the pagination html markup automatically to it.
1 2 3 4 5 6 7 8 9 10 11 |
$(document).ready(function(){ //slider init $("#slides").responsiveSlides({ speed: 700, //Speed of the transition timeout: 3500, //Time between slide transitions pager: true //Show the pagination }); }); |
Save the file, and open “index.html” in the browser, you should see something like the image bellow.
Services :
First, let’s add the html markup for the services section, copy and past the code below right below the slider html markup.
html :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<!-- Services Section --> <section class="services container clearfix"> <!-- Services Title --> <div class="section_title animated wow fadeInUp"> <h2>What We Do.</h2> </div> <!-- Services List --> <div class="services_list"> <ul> <li class="animated wow fadeInRight" data-wow-delay=".2s"> <h3>We Design.</h3> <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p> <a href="#">read more<span class="arrow">→</span></a> </li> <li class="animated wow fadeInRight" data-wow-delay=".3s"> <h3>We Innovate.</h3> <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p> <a href="#">read more<span class="arrow">→</span></a> </li> <li class="animated wow fadeInRight" data-wow-delay=".4s"> <h3>We Create.</h3> <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p> <a href="#">read more<span class="arrow">→</span></a> </li> </ul> </div> </section><!-- end services --> |
The html above consist of a section <section> with three classes “services” class, “container” class to center the section, and “clearfix” class to clear the floated elements inside it, we added a “section_title” div which will act like a container for the services section title <h2>, and three additional classes, “animated” and “fadeInUp” classes are both already styled inside the animate.css, we used the “fadeInUp” class to add a cool fade in effect to the services section title, you can find more effects here, the “wow” class will be used by the “wow.js” library, to reveal the animations when you scroll down to the services section.
Right below the “section_title” div, we added the “services_liste” div, it consist of an unordered list <ul> with three list items, each list item contains the service title <h3>, a short description of the service <p> and a read more link <a>, notic we applied the same three classes as the “section_title” div to the three list items <li>, but instead of the “fadeInUp” effect we used the “fadeInRight” effect, we specified a delay before the animation starts for each list item using the data-wow-delay attribute.
css :
Now lets style the services section :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
/* services */ .services{ padding: 100px 0; border-bottom: 1px solid #f5f5f5; } .section_title{ width: 333px; height: auto; margin-right: 50px; float: left; } .section_title h2{ color: #5e5e5e; font-family: "raleway-bold", arial; font-size: 50px; font-weight: bold; margin: 0 0 40px 0; } .services h2, .services h3{ margin: 0; } .services .services_list{ width: 717px; float: right; } .services .services_list ul{ list-style: none; } .services .services_list ul li{ width: 212px; float: left; margin-right: 40px; } .services .services_list ul li:last-child{ margin-right: 0; } .services .services_list h3{ color: #5e5e5e; font-family: "raleway-bold", arial; font-size: 20px; font-weight: bold; margin-bottom: 40px; } .services .services_list p{ color: #8c8b8b; font-family: "raleway-regular"; font-size: 14px; margin-bottom: 30px; line-height: 24px; letter-spacing: .5px; } .services .services_list a{ text-decoration: none; color: #6c6c6c; font-family: "raleway-regular"; font-size: 13px; letter-spacing: .5px; } .services .services_list a .arrow{ margin-left: 5px; font-size: 16px; } |
As you can see the styling for services section is pretty simple and basic, we set the top and bottom padding to 100px to get enough space between the slider and the projects section which we will add later, we added a separator to separate the projects section from services section by using a bottom border, we floated the services list items “li” to the left to put the them in the same level, then we styled the services title “h3”, the services short description “p” and the read more link “a”.
js :
Now we are going to activate the wow.js, in order to reveal the animation effects we applied previously to the services section title and the list of services when we scroll down the page.
1 2 3 4 5 6 7 8 9 |
//wow.js init wow = new WOW( { animateClass: 'animated', mobile: false, offset: 100 } ); wow.init(); |
Copy and paste the javascript code above right below the slider code inside your “main.js” file, you should get the same result as the image below, the animation effects will start when you scroll down to the services section.
Projects Section :
html :
Go-ahead and past the html markup right below the services section html code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<!-- Projects Section --> <section class="projects container clearfix"> <!-- Projects Title --> <div class="section_title animated wow fadeInUp"> <h2>Our Work.</h2> <a href="" class="details">More Projects<span class="arrow">→</span></a> </div> <!-- Projects List --> <div class="projects_list clearfix"> <ul> <li class="animated wow fadeInRight" data-wow-delay=".2s"> <a href="#"> <span class="p_logo1"></span> </a> </li> <li class="animated wow fadeInRight" data-wow-delay=".3s"> <a href="#"> <span class="p_logo2"></span> </a> </li> </ul> </div> </section><!-- end projects --> |
The projects section is similar to the services section, it consist of a div with the class “section_title” wrapping the title <h2> and a more projects link <a>, notice we added a span inside the anchor link to hold the arrow, we used the html character “→” to add the little arrow, below the “section_title” div we add a “project_list” div containing an unordered list <ul>, inside each list item <li>, we put an anchor link with a span to hold the projects logo.
css :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
/* projects */ .projects{ padding: 100px 0; border-bottom: 1px solid #f5f5f5; } .projects .section_title .details{ text-decoration: none; color: #6d6d6d; font-family: "raleway-regular", arial; font-size: 14px; letter-spacing: .5px; } .projects .section_title .details .arrow{ margin-left: 5px; } .projects_list ul{ list-style: none; } .projects_list ul li a{ display: block; width: 325px; height: 300px; float: left; margin-right: 50px; background: #f2f2f2; position: relative; border: 4px solid #eeeded; transition:all .2s linear; -o-transition:all .2s linear; -moz-transition:all .2s linear; -webkit-transition:all .2s linear; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; } .projects_list ul li:last-child a{ margin-right: 0; } .projects_list ul li a:hover{ background: #ff4242; border: 4px solid #ec3636; } .projects_list ul li a span{ position: absolute; height: 124px; margin-top: -62px; top: 50%; transition:all .2s linear; -o-transition:all .2s linear; -moz-transition:all .2s linear; -webkit-transition:all .2s linear; } .projects_list ul li a .p_logo1{ background: url('../img/p_logo1.png') no-repeat; width: 58px; height: 124px; left: 50%; margin-left: -29px; } .projects_list ul li a:hover .p_logo1{ background: url('../img/p_logo1_hover.png') no-repeat; } .projects_list ul li a .p_logo2{ background: url('../img/p_logo2.png') no-repeat; width: 85px; left: 50%; margin-left: -42.5px; } .projects_list ul li a:hover .p_logo2{ background: url('../img/p_logo2_hover.png') no-repeat; } |
The css above is quite simple, we started by styling the “projects” section, with a padding of 100px for the top and bottom to space the content inside it form the top and bottom, we used a bottom border as a separator, then we moved to the “more projects” link and the little arrow inside it, we set the nested links “a” inside the unordered list items “li” display property to block, then we gave it a fixed height and width to make them look like a box, we applied a nice red color to the background for the hover state, then we used the css trick we applied previously to the slider caption, to center the projects logos vertically, and finally we added the the projects logos we slices in the beginning of this tutorial for the normal and the hover effect.
Open the “index.html” file in the browser, and see the result similar to the image below.
Clients section :
html :
The client section is also similar to the services and projects section, it’s consist of a title and list of clients logos, we used the logos we sliced in the beginning of this tutorial, i think the css code below is self-explanatory, so just copy and paste it right below the project section html markup in the “index.html” file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<!-- Clients Section --> <section class="clients container"> <!-- Clients section Title --> <div class="section_title animated wow fadeInUp"> <h2>Our Happy Clients.</h2> </div> <!-- Clients List --> <div class="client_list clearfix"> <ul> <li class="animated wow fadeInRight" data-wow-delay=".2s"> <img src="img/client_logo.jpg" alt="Client 1" /> </li> <li class="animated wow fadeInRight" data-wow-delay=".3s"> <img src="img/client_logo.jpg" alt="Client 1" /> </li> <li class="animated wow fadeInRight" data-wow-delay=".4s"> <img src="img/client_logo.jpg" alt="Client 1" /> </li> <li class="animated wow fadeInRight" data-wow-delay=".5s"> <img src="img/client_logo.jpg" alt="Client 1" /> </li> </ul> </div> </section><!-- end clients --> |
css :
Let’s style the client section now, the css code below for the clients section is very simple, the “section_title”” div is already styled, we removed the default list style, and floated the client logos list “li” to the left to put them in the same level.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/* clients */ .clients{ padding: 100px 0; } .client_list ul{ list-style: none; } .client_list ul li{ float: left; margin-right: 50px; } .client_list ul li:last-child{ margin-right: 0; } |
The result should be similar to the image below.
Call To Action section :
html :
1 2 3 4 5 6 7 8 9 |
<!-- Call To Action Section --> <section class="cta"> <div class="container animated wow fadeInUp"> <h3 class="cta_title">Ready To Start Your Project?</h3> <a href="#" class="cta_button">yes we are ready →</a> </div> </section><!-- end cta(call to action) --> |
The call to action section “cta”, is made of an <h3> title with the class “cta_title”, and an anchor link <a> we will style it later to make look like a button.
css :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
/* call to action */ .cta{ width: 100%; padding: 100px 0; background: #fafafa; text-align: center; } .cta .cta_title{ color: #5e5e5e; font-family: "raleway-bold", arial; font-size: 25px; font-weight: bold; text-transform: uppercase; margin-bottom: 70px; } .cta a{ text-decoration: none; padding: 20px 40px; background-color: #ff4141; color: #fff; font-family: "raleway-regular", arial; font-size: 18px; letter-spacing: .5px; border-radius: 2px; -o-border-radius: 2px; -moz-border-radius: 2px; -webkit-border-radius: 2px; transition:all .2s linear; -o-transition:all .2s linear; -moz-transition:all .2s linear; -webkit-transition:all .2s linear; } .cta a:hover{ background: #f23131; } |
For the cta(call to action) section styling, we set the “.cta” section to 100%, we want it to take the full width of the screen, we used a soft gray color #fafafa for the background color and we centered elements inside it using the text-align property, then we styled the “h3” title and the anchor link “a”, to make the anchor link “a” look like a big button, we set the top and bottom padding to 20px, the left and right padding to 40px and we applied a nice red color #ff4141 to the background, we used the new css3 property border-radius to get a 2px rounded corners, we added the transition css3 property to add the fade effect to the button for the hover state, we changed the cta button “.cta_button” background red color to a softer red for the hover state using the pseudo element “:hover”.
Now save your files and open them in the browser to see the result, the screen above is the final result.
Footer :
At the first look, the footer section looks a little bit complicated, but actually it’s very simple and easy to understand, let’s start first by adding the html markup to the “index.html” file, place below the call to action section html code.
html :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
<!-- Footer Section --> <footer class="clearfix"> <div class="container"> <!-- Copyrights --> <div class="copyright animated wow fadeInUp"> <img src="img/footer_logo.png" alt="Heros." class="footer_logo"> <p>© 2014 copyright pixelhint - All rights reserved</p> <p>More free templates @ <a href="http://pixelhint.com">Pixelhint.com</a></p> </div> <div class="footer_links"> <!-- Social Media Links --> <div class="sm columns animated wow fadeInRight" data-wow-delay=".2s"> <h3 class="columns_title">Stay Tuned</h3> <ul> <li> <a class="facebook" href="#">Facebook</a> </li> <li> <a class="twitter" href="#">Twitter</a> </li> <li> <a class="google" href="#">Google Plus</a> </li> </ul> </div> <!-- About Links --> <div class="about columns animated wow fadeInRight" data-wow-delay=".3s"> <h3 class="columns_title">About</h3> <ul> <li> <a href="#">Our Company</a> </li> <li> <a href="#">Our Team</a> </li> <li> <a href="#">Blog</a> </li> </ul> </div> <!-- Address --> <div class="address columns animated wow fadeInRight" data-wow-delay=".4s"> <h3 class="columns_title">Address</h3> <p>1012 14th Street Northwest</p> <p>Washington, DC 20005</p> <p class="phone">(202) 737-1499</p> </div> </div> </div> </footer><!-- end footer --> |
We started by creating the footer section using the html5 tag <footer>, notice we added the “clearfix” class to clear the floated elements inside it, then we added a “copyright” div which will hold the logo image <img> and the copyright text paragraph <p>, right below the “copyright” div we added the “footer_links” div which contains three div’s “sm” (abbreviation of social media), “about” and “address” each div represent a column, inside the “sm” div we put a title <h3> and an unordered list <ul>, each list item <li> is wrapping a link to a social media network, the “about” div is similar to “sm” div, it consist of a title <h3> and an unordered list <ul> with nested anchor links <a> linking to inner pages, the “address” div consist of a title <h3> like the other two columns, the address text <p> and a phone number.
css :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
/* footer */ footer{ padding: 100px 0; } footer .copyright{ width: 333px; height: auto; margin-right: 50px; float: left; } footer .copyright .footer_logo{ margin-bottom: 38px; } footer .copyright p{ color: #8d8b8b; font-family: "raleway-regular", arial; font-size: 12px; letter-spacing: .5px; margin-bottom: 15px; } footer .copyright p a{ text-decoration: none; font-family: "raleway-bold", arial; font-weight: bold; color: #8d8b8b; } |
First, we used top and bottom padding of 100px to space the footer area, then we floated the “.copyright” div to left and the “.footer_links” div to right, we applied some basic style for the text paragraph “p” inside the “.copyright” div.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
footer .footer_links{ width: 717px; float: right; } footer .footer_links .columns{ width: 212px; float: left; margin-right: 40px; } footer .footer_links .columns:last-child{ margin-right: 0; } footer .footer_links .columns_title{ color: #5e5e5e; font-family: "raleway-bold", arial; font-size: 18px; font-weight: bold; margin-bottom: 50px; } |
We floated the “.footer_links” div to the right, to put it side-by-side with the “copyright” div, then we set a fixed width for the div’s with the class “columns” and floated them to left to put them in the same level, after that we set the margin-right to 40px to get enough space between each column, we used the css3 property :last-child to remove the right margin from the last column inside the “footer_links” div, and we applied some styling the title “.columns_title” of each column.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
footer .footer_links ul li{ list-style: none; display: block; margin-bottom: 30px; } footer .footer_links ul li a{ text-decoration: none; color: #8c8b8b; font-family: "raleway-regular", arial; font-size: 14px; letter-spacing: .5px; transition:all .2s linear; -o-transition:all .2s linear; -moz-transition:all .2s linear; -webkit-transition:all .2s linear; } footer .footer_links ul li a:hover{ color: #3c3c3c; } |
In this piece of code, we began by styling the unordered lists “ul” inside the “.footer_links” div, we removed the default list style, we set the display property to block to place each list item under the other, with a bottom space of 30px, then we styled the nested anchor links “a”, and added the hover state effect.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
footer .sm ul li a:before{ content:""; display: inline-block; width: 15px; margin-right: 20px; } footer .sm ul li .facebook:before{ height: 14px; background: url('../img/fb.png') no-repeat; vertical-align: middle; } footer .sm ul li .twitter:before{ height: 15px; background: url('../img/twitter.png') no-repeat; vertical-align: middle; } footer .sm ul li .google:before{ height: 14px; background: url('../img/google.png') no-repeat; vertical-align: middle; } |
We add the social media icons we sliced previously, to each social network by using the pseudo element “:before”.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
footer .address p{ color: #8c8b8b; font-family: "raleway-regular", arial; font-size: 14px; margin-bottom: 30px; letter-spacing: .5px; } footer .address .phone{ display: block; font-family: "raleway-bold", arial; font-weight: bold; } |
Lastly, we applied some css styling to the address text “p” and the phone number, we applied the “raleway-regular” font using the font-family property, and used the letter-spacing to space the text characters, we also applied the “raleway-bold” font to the phone number, and set the font-weight property to bold.
Save the files and see the result, below is the final result.
We are done.
The final result is a beautiful website template, with cool effects we added thanks to the “animate.css”, “Jquery.js” and “wow.js” library, we hope you have learned something new from this tutorial on how to convert a psd file to HTML5/CSS3 template, if you have any questions or suggestions please let us know in the comment section below.
Get Free Update !
Join our mailing list today and receive exclusive web design tutorials and high quality free web resources.
-
alios
-
Pixelhint
-
-
Quoc Nguyen
-
Pixelhint
-
-
nayelnoorani
-
Pixelhint
-
Al Hassan
-
-
-
Felipe Rayces
-
klajdi
-
hisabudin siddiqui
-
Dendra I. Maulana
-
Pixelhint
-
-
Dalmatinac
-
Pixelhint
-
-
Shaquille Yang
-
Pixelhint
-
-
Oleg Kogut