domingo, 26 de junio de 2011
Free Website Template with jQuery Carousel in the Header. Check out!
Would you like to get a fresh freebie from the professionals? Today we are glad to present you the solution that is perfect for creating the project that deals with software. Designed by the team from TemplateMonster.com, this Free Website Template with jQuery Carousel in the Header features everything you need to start the successful web presence. This theme goes with cool jQuery slider that brings dynamics to the homepage, makes it appealing and in such a way helps interact effectively with your customers. If you want to check out its quality and see its visual effectiveness, feel free to look at its free template live demo.
Speaking about the general characteristics of this theme, we should mention that it is presented in 5 pages: Home, Features, Downloads, Support, Contacts. It can be delivered in two packages – with PSD source files included and without them. If you need PSD source files, please go to the template download page at TemplateMonster to leave the e-mail address that you want the free template ZIP package to be delivered to.
Free Website Template with jQuery Carousel in the Header:
and here are 3D Models from this template:
"
domingo, 19 de junio de 2011
jueves, 16 de junio de 2011
Five Useful Interactive CSS/jQuery Techniques Deconstructed
With the wide variety of CSS3 and JavaScript techniques available today, it’s easier than ever to create unique interactive websites that delight visitors and provide a more engaging user experience.
In this article, we’ll walk through five interactive techniques that you can start using right now. We’ll cover:
- Animated text effects,
- Animated images without GIFs,
- More engaging drop-down menus,
- Fancier slideshow navigation,
- Animated icons for the hover state of buttons.
Besides learning how to accomplish these specific tasks, you’ll also master a variety of useful CSS and jQuery tricks that you can leverage when creating your own interactive techniques. The solutions presented here are certainly not perfect, so any thoughts, ideas and suggestions on how you would solve these design problems would be very appreciated.
So, let’s dive in and start building more exciting websites!
1. Extruded Text Effect
The footer of David DeSandro’s website uses extruded text that animates on mouseover. This interactive text effect is a quick and impressive way to add some flare to your website. With only a few lines of CSS3, we can make the text appear to pop out of the page in three dimensions.
First let’s set up some text (the code is copied from the original site):
<span class="extruded">Extrude Me</span>
And some basic styling (the code is copied from the original site):
body { background-color: #444; text-align: center; } .extruded { color: #888; font-family: proxima-nova-1, proxima-nova-2, 'Helvetica Neue', Arial, sans-serif; font-size: 48px; font-weight: bold; text-shadow: #000 3px 3px; }
Here, we’ve applied some basic styles and added a
text-shadow
. But this text-shadow doesn’t look three-dimensional; to accomplish the extruded effect, we’ll need to add more text-shadows:text-shadow: #000 1px 1px, #000 2px 2px, #000 3px 3px;
This will add three different text-shadows to our text, stacked on top of each other to create the three dimensional appearance we want.
Styling the Hover State
Next, let’s add a hover state with a bigger text-shadow:
.extruded:hover { color: #FFF; text-shadow: #58E 1px 1px, #58E 2px 2px, #58E 3px 3px, #58E 4px 4px, #58E 5px 5px, #58E 6px 6px; }
Here, we’ve added three more text-shadows to increase the depth of the extrude effect. But this effect alone is too flat; we want the text to look like it’s popping off the page. So, let’s reposition the text to make it appear to grow taller from the base of the extruded section:
.extruded { position: relative; } .extruded:hover { color: #FFF; text-shadow: #58E 1px 1px, #58E 2px 2px, #58E 3px 3px, #58E 4px 4px, #58E 5px 5px, #58E 6px 6px; left: -6px; top: -6px; }
Now in the hover state, the extruded text moves up the same distance as our max
text-shadow
value. We also added position: relative
, which must be attached to the base state, not just the hover state, or else it will cause problems when we animate it.Animating the Transition
Next, we can add a CSS3 transition to our text to animate the color change and extrude effect:
.extruded { -moz-transition: all 0.3s ease-out; /* FF3.7+ */ -o-transition: all 0.3s ease-out; /* Opera 10.5 */ -webkit-transition: all 0.3s ease-out; /* Saf3.2+, Chrome */ transition: all 0.3s ease-out; }
This triggers a smooth animation for our different CSS changes on hover. While it doesn’t work in all browsers, it does degrade nicely to the basic hover effect.
Bringing it all together:
body { background-color: #444; text-align: center; } .extruded { color: #888; font-family: proxima-nova-1, proxima-nova-2, 'Helvetica Neue', Arial, sans-serif; /* the original site doesn't use the @font-face attribute */ font-size: 48px; font-weight: bold; text-shadow: #000 1px 1px, #000 2px 2px, #000 3px 3px; position: relative; -moz-transition: all 0.3s ease-out; /* FF3.7+ */ -o-transition: all 0.3s ease-out; /* Opera 10.5 */ -webkit-transition: all 0.3s ease-out; /* Saf3.2+, Chrome */ transition: all 0.3s ease-out; } .extruded:hover { color: #FFF; text-shadow: #58E 1px 1px, #58E 2px 2px, #58E 3px 3px, #58E 4px 4px, #58E 5px 5px, #58E 6px 6px; left: -6px; top: -6px; }
Shortcomings
While applying several CSS3 text-shadows works well when the text is static, it falls a bit short when used alongside the transition animation.
In short, the biggest text-shadow animates just fine, but the other text-shadows aren’t applied until the animation completes. This causes a quick correction: the browser stutters with a basic drop-shadow before filling in the rest diagonally.
Fortunately, we can make this drawback relatively unnoticeable, provided that we follow a few style guidelines. Basically, we want to hide the bulk of the extruded portion with the top text. This means that we should generally use this effect with bolder fonts, such as the Proxima Nova family used by David DeSandro. Also, we should be careful to avoid text-shadows that are too big for the font. Tweak your settings with this in mind until the animated extrude looks believable.
Finally, this technique will not work in IE, because
text-shadow
is unsupported in all versions of IE (even IE9).2. Animating A Background Image
While we can easily animate text with a few lines of code, animating an image usually requires bigger and slower assets, such as animated GIFs or Flash or HTML5 video. While complex animations will still depend on these technologies, we can create a compelling illusion of animation using CSS alone.
Love Nonsense uses a hover effect to alter the color of the images on the website. The trick here is to use a transparent PNG with a background color. The color of the PNG should match the website’s background, so that all of the transparent areas in the PNG show up when filled with a background color. Thus, the PNG should contain the negative space of the image you want to display (i.e. the shape you want should be transparent, and everything else should be the same color as the background).
Here’s an example of the Smashing Magazine logo with negative space:
Notice in the demo how when the background color is set to orange, it starts to look more like the real thing.
The Code
First, let’s do some basic mark-up:
<div class="post-wrapper"> <h2 class="post-title"> This is the title you hover over <img src="knockout-image.png" class="post-image" alt="" /> </h2> <p>Some more text here.</p> </div>
Here we include a post with a title, our knock-out image and a paragraph of text.
Next, let’s set up some static styles:
.post-wrapper { position: relative; padding-left: 240px; } .post-image { position: absolute; top: 0; left: 0; background-color: #bbb; } .post-title { color: #037072; }
Here, we’ve set up the post’s wrapper with
position: relative
and with enough padding on the left side to absolutely position the image to the left of our post. We’ve also added a background color to our image; so now the positive space in our PNG shows up as light gray.Next, let’s add some hover effects:
.post-title:hover { color: #d63c25; } .post-title:hover .post-image { background-color: #f04e36; }
Now, when we hover over the title or the image, both will change color.
We can take this effect a step further by animating the transition:
.post-image { -webkit-transition: background-color 400ms ease-in; -moz-transition: background-color 400ms ease-in; transition: background-color 400ms ease-in; } .post-title { -webkit-transition: color 400ms ease-in; -moz-transition: color 400ms ease-in; transition: color 400ms ease-in; }
Here, we’ve added a CSS3 transition to both the image and the title, which will make for a smooth color change animation.
Unfortunately, CSS3 transitions are not currently supported in IE9. However, even in unsupported browsers, the color change will still occur — it just won’t have a smooth animation.
If complete cross-browser support for the animation is important, you could always provide a jQuery version of the animation for unsupported browsers. Bear in mind, though, that jQuery’s
animate()
method does not support color animations, so you’ll need to use a color plug-in.Putting all the CSS together:
.post-wrapper { position: relative; padding-left: 240px; } .post-image { position: absolute; top: 0; left: 0; background-color: #bbb; -webkit-transition: background-color 400ms ease-in; -moz-transition: background-color 400ms ease-in; transition: background-color 400ms ease-in; } .post-title { color: #037072; -webkit-transition: color 400ms ease-in; -moz-transition: color 400ms ease-in; transition: color 400ms ease-in; } /* add the hover states */ .post-title:hover { color: #d63c25; } .post-title:hover .post-image { background-color: #f04e36; }
3. Mega Dropdown
One common design problem with dropdown menus is that they often contain a lot of items. Instead of presenting all of its items in a long single column, Bohemia Design uses a multi-column dropdown. This approach not only looks great, but provides an opportunity to group the links and highlight the most important ones.
Let’s recreate this menu using CSS and jQuery.
Building the Tabs
Ideally, we would start with a lean and simple mark-up…
<nav> <li><a href="#">Tab 1</a></li> <li><a href="#">Tab 2</a></li> <li><a href="#">Tab 3</a></li> <li><a href="#">Tab 4</a></li> <li><a href="#">Tab 5</a></li> </nav>
…and use
nav li a
, nav > li
or nav li
to style the list items in the navigation. The child selector doesn’t work in IE6 and nav li
would cause problems since there are additional LIs nested in the content area of the dropdown. If you absolutely need the site to work for IE6 users as well (and that’s what you sometimes will have to do), you’ll need to have markup similar to the original mark-up in this example:<ul id="main-nav"> <li class="main-nav-item"> <a href="#" class="main-nav-tab">Tab 1</a> </li> <li class="main-nav-item"> <a href="#" class="main-nav-tab">Tab 2</a> </li> <li class="main-nav-item"> <a href="#" class="main-nav-tab">Tab 3</a> </li> <li class="main-nav-item"> <a href="#" class="main-nav-tab">Tab 4</a> </li> <li class="main-nav-item"> <a href="#" class="main-nav-tab">Tab 5</a> </li> </ul>
Next, let’s style these five tabs:
#main-nav { width: 800px; height: 50px; position: relative; list-style: none; padding: 0; } #main-nav .main-nav-item { display: inline; } #main-nav .main-nav-tab { float: left; width: 140px; height: 30px; padding: 10px; line-height: 30px; text-align: center; color: #FFF; text-decoration: none; font-size: 18px; }
Although a lot of the CSS is specific to our example, there are a few important styles to note.
First, we’ve defined a height and width for our overall tab area and matched the total height and width of all five tabs, so that we can position the dropdown correctly. Next, we’ve defined
position: relative
for the tab wrapper, which will allow us to position the dropdown absolutely.Then, we added
list-style: none
to the list wrapper, and display: inline
to each list item, to eliminate any list styling.Finally, we floated all of the tab links to the left.
Building the Dropdown
Now, let’s build the dropdown mark-up in one of our tab wrappers:
<li class="main-nav-item"> <a href="#" class="main-nav-tab">Tab 1</a> <div class="main-nav-dd"> <div class="main-nav-dd-column"> Column content here </div> </div> <div class="main-nav-dd"> <div class="main-nav-dd-column"> Column content here </div> </div> <div class="main-nav-dd"> <div class="main-nav-dd-column"> Column content here </div> </div> </li>
Next, let’s style this dropdown:
#main-nav .main-nav-dd { position: absolute; top: 50px; left: 0; margin: 0; padding: 0; background-color: #FFF; border-bottom: 4px solid #f60; } #main-nav .main-nav-dd-column { width: 130px; padding: 15px 20px 8px; display: table-cell; border-left: 1px solid #ddd; *float: left; *border-left: 0; } #main-nav .main-nav-dd-column:first-child { border-left: 0; }
Here, we’ve positioned the dropdown absolutely, directly beneath the first tab.
Let’s set
display: table-cell
on all of the column wrappers, so that they display next to each other. But table-cell
is not supported in IE6 or 7, so we’ve used an attribute hack as an alternative for IE6 and 7. This hack places an asterisk (*
) before each of the attributes that are specific to IE6 and 7.Thus, we’ve defined a backup for unsupported IEs, which is simply
float: left
. This works almost as well as display: table-cell
, except that the floated elements don’t match each other’s height, so the borders between columns don’t line up. To avoid this minor issue, we simply remove the border-left
using the same asterisk hack.Finally, we remove the left border from the first column for all browsers. Although the
:first-child
pseudo-class doesn’t work properly in IE6, fortunately it doesn’t make a difference, because we’ve already hidden the borders in these browsers.Adding the Interaction
We’ve built the mark-up and styles for our dropdown, but we still need to make the menu interactive. Let’s use jQuery to add a class to show and hide the dropdown:
$(function() { var $mainNav = $('#main-nav'); $mainNav.children('.main-nav-item').hover(function(ev) { // show the dropdown $(this).addClass('main-nav-item-active'); }, function(ev) { // hide the dropdown $(this).removeClass('main-nav-item-active'); }); });
Here, we’ve attached a hover listener to each list item, which adds and removes the class
main-nav-item-active
. Attach this to the list item rather than the tab itself, or else the dropdown will disappear when the user mouses off the tab and into the dropdown area.Now we can use this class hook to hide and show the dropdown with CSS:
#main-nav .main-nav-dd { display: none; } #main-nav .main-nav-item-active .main-nav-dd { display: block; }
Let’s use the
active
class to style the active tab:#main-nav .main-nav-item-active .main-nav-tab { background-color: #FFF; color: #f60; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; }
Here, we’ve changed the background and text colors and rounded the top corners (in supported browsers).
Positioning the Dropdown
Now the basic mouse interaction has been built and the dropdown displays on mouseover. Unfortunately, it is still not positioned correctly under each tab, so let’s add some more code to our hover events:
$(function() { var $mainNav = $('#main-nav'); $mainNav.children('.main-nav-item').hover(function(ev) { var $this = $(this), $dd = $this.find('.main-nav-dd'); // get the left position of this tab var leftPos = $this.find('.main-nav-tab').position().left; // position the dropdown $dd.css('left', leftPos); // show the dropdown $this.addClass('main-nav-item-active'); }, function(ev) { // hide the dropdown $(this).removeClass('main-nav-item-active'); }); });
Here, we use jQuery’s
position()
method to get the left offset from the current tab. We then use this value to position the dropdown directly beneath the appropriate tab.However, with the tabs on the right side, the dropdown menu will end up poking out of the tab area. Besides looking bad, this could lead to overflow issues, with portions of the dropdown falling outside of the browser window.
Let’s fix the positioning with some JavaScript:
$(function() { var $mainNav = $('#main-nav'), navWidth = $mainNav.width(); $mainNav.children('.main-nav-item').hover(function(ev) { var $this = $(this), $dd = $this.find('.main-nav-dd'); // get the left position of this tab var leftPos = $this.find('.main-nav-tab').position().left; // get the width of the dropdown var ddWidth = $dd.width(), leftMax = navWidth - ddWidth; // position the dropdown $dd.css('left', Math.min(leftPos, leftMax) ); // show the dropdown $this.addClass('main-nav-item-active'); }, function(ev) { // hide the dropdown $(this).removeClass('main-nav-item-active'); }); });
Here, we start by finding the overall width of the tab area. Because recalculating the width for each tab is not necessary, we can define it outside of our hover listener.
Next, we find the width of the dropdown and determine the maximum left value, which is the overall tab width minus the width of the dropdown.
Finally, instead of always positioning the dropdown directly beneath the tab, we use the
Math.min()
method to pick the lowest between the tab offset and the maximum left value.Thus, we confine the dropdown to the area beneath the tabs and avoid any content issues.
Other Approaches
While this script is fully functional, we could still improve the user experience. Currently, when the user mouses away from the dropdown, the menu hides immediately. You could build a delay using
setTimeout()
to ensure that the dropdown remains visible when the user mouses away and then quickly mouses back. This creates a better experience, because it avoids hiding the dropdown during accidental movements.If you’d rather avoid
setTimeout()
, you could also look into the hoverIntent jQuery plug-in, which makes fine-tuned control over mouse actions much easier.Besides improving the user experience, you could also avoid jQuery altogether in all browsers except IE6.
Instead of using jQuery’s
hover()
listener, we could use the CSS pseudo-class :hover
to hide and show the dropdown.One downside with the CSS-only solution is that you can’t build a delay for the
:hover
pseudo-class.Also, you will have to position the dropdown manually under each tab to avoid the overflow issues. Alternatively, if you aren’t concerned with overflow issues, you could attach
position: relative
to each list item and avoid setting any positions manually.Finally, if you’re supporting IE6, make sure to include the script above as a backup for IE6 (but don’t include it for other browsers).
4. Animated Slideshow Navigation
There are a lot of JavaScript slideshow techniques, but the animated navigation on McKinney is a fresh, subtle approach.
Basic jQuery Slideshow
Let’s build something similar. We’ll start with some mark-up for a basic slideshow:
<div id="slideshow"> <div id="slideshow-reel"> <div class="slide"> <h1>Slide 1</h1> </div> <div class="slide"> <h1>Slide 2</h1> </div> <div class="slide"> <h1>Slide 3</h1> </div> <div class="slide"> <h1>Slide 4</h1> </div> <div class="slide"> <h1>Slide 5</h1> </div> <div class="slide"> <h1>Slide 6</h1> </div> </div> </div>
Here we’ve set up six slides, which can be filled with any content we need. Let’s set up some CSS to display the slides as a horizontal reel:
#slideshow { width: 900px; height: 500px; overflow: hidden; position: relative; } #slideshow-reel { width: 5400px; height: 450px; position: absolute; top: 0; left: 0; } #slideshow-reel .slide { width: 900px; height: 450px; float: left; background-color: gray; }
Here, we’ve defined the dimensions of the slideshow, along with
overflow: hidden
to hide the other slides in the reel. We’ve also defined the dimensions of the reel: with six slides at 900 pixels each, it is 5400 pixels wide. (You could also just set this to a really high number, like 10000 pixels.) Then, we absolutely positioned the reel inside the slideshow (which has position: relative
). Finally, we defined the dimensions for all of the individual slides and floated them to the left to fill up our reel.Basic Slideshow Animation
Now, let’s add some jQuery to animate this slideshow:
$(function() { function changeSlide( newSlide ) { // change the currSlide value currSlide = newSlide; // make sure the currSlide value is not too low or high if ( currSlide > maxSlide ) currSlide = 0; else if ( currSlide < 0 ) currSlide = maxSlide; // animate the slide reel $slideReel.animate({ left : currSlide * -900 }, 400, 'swing', function() { // set new timeout if active if ( activeSlideshow ) slideTimeout = setTimeout(nextSlide, 1200); }); } function nextSlide() { changeSlide( currSlide + 1 ); } // define some variables / DOM references var activeSlideshow = true, currSlide = 0, slideTimeout, $slideshow = $('#slideshow'), $slideReel = $slideshow.find('#slideshow-reel'), maxSlide = $slideReel.children().length - 1; // start the animation slideTimeout = setTimeout(nextSlide, 1200); });
Here, we’ve started by creating the function
changeSlide()
, which animates the slide reel. This function accepts an index for the next slide to show, and it checks to make sure that the value isn't too high or low to be in the reel.Next, it animates the slide reel to the appropriate position, and then finishes by setting a new timeout to trigger the next iteration.
Finally, we’ve built the function
nextSlide()
, which simply triggers changeSlide()
to show the next slide in the reel. This simple function is just a shortcut to be used with setTimeout()
.The Left and Right Navigation
Next, let's set up the left and right arrows in the slideshow, starting with the mark-up:
<a href="#" id="slideshow-prev"></a> <a href="#" id="slideshow-next"></a>
For simplicity's sake, we've added the mark-up to the HTML source. Appending it to the jQuery is often a better approach, to ensure that the controls appear only when they are usable.
Let's style these arrows with CSS:
#slideshow-prev, #slideshow-next { display: block; position: absolute; top: 190px; width: 0; height: 0; border-style: solid; border-width: 28px 21px; border-color: transparent; outline: none; } #slideshow-prev:hover, #slideshow-next:hover { opacity: .5; filter: alpha(opacity=50); -ms-filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)'; } #slideshow-prev { left: 0; border-right-color: #fff; } #slideshow-next { right: 0; border-left-color: #fff; }
We’ve positioned the arrows absolutely within the slideshow frame and added an opacity change on hover. In our example, we’ve used a CSS triangle trick to style the arrows with straight CSS, but feel free to use an image if you want richer graphics.
Finally, let's build the required interaction into our JavaScript:
$(function() { function changeSlide( newSlide ) { // cancel any timeout clearTimeout( slideTimeout ); // change the currSlide value currSlide = newSlide; // make sure the currSlide value is not too low or high if ( currSlide > maxSlide ) currSlide = 0; else if ( currSlide < 0 ) currSlide = maxSlide; // animate the slide reel $slideReel.animate({ left : currSlide * -900 }, 400, 'swing', function() { // hide / show the arrows depending on which frame it's on if ( currSlide == 0 ) $slidePrevNav.hide(); else $slidePrevNav.show(); if ( currSlide == maxSlide ) $slideNextNav.hide(); else $slideNexNav.show(); // set new timeout if active if ( activeSlideshow ) slideTimeout = setTimeout(nextSlide, 1200); }); // animate the navigation indicator $activeNavItem.animate({ left : currSlide * 150 }, 400, 'swing'); } function nextSlide() { changeSlide( currSlide + 1 ); } // define some variables / DOM references var activeSlideshow = true, currSlide = 0, slideTimeout, $slideshow = $('#slideshow'), $slideReel = $slideshow.find('#slideshow-reel'), maxSlide = $slideReel.children().length - 1, $slidePrevNav = $slideshow.find('#slideshow-prev'), $slideNextNav = $slideshow.find('#slideshow-next'); // set navigation click events // left arrow $slidePrevNav.click(function(ev) { ev.preventDefault(); activeSlideshow = false; changeSlide( currSlide - 1 ); }); // right arrow $slideNextNav.click(function(ev) { ev.preventDefault(); activeSlideshow = false; changeSlide( currSlide + 1 ); }); // start the animation slideTimeout = setTimeout(nextSlide, 1200); });
Here, we've added quite a bit of new interaction. First, look at the bottom of this script, where we've added click event listeners to both of our navigational items.
In these functions, we have first set
activeSlideshow
to false
, which disables the automatic animation of the reel. This provides a better user experience by allowing the user to control the reel manually. Then, we trigger either the previous or next slide using changeSlide()
. Next, in the changeSlide()
function, we've added a clearTimeout(). This works in conjunction with the activeSlideshow
value, cancelling any hanging iteration from a setTimeout
.Finally, in the callback of the
animate()
function, we've added some code to hide and show the arrow navigation. This hides the left arrow when the slideshow is showing the left-most slide, and vice versa.Animating the Bottom Navigation
The basic slideshow works with the previous and next arrows. Let's take it to the next level by adding the animated navigation. Please note that I am using a more complex markup because it avoids the use of images and is ultimately simpler. It would have to use three background images otherwise — one for the center sections and one for each cap to allow the clickable areas to be larger). However, you could clean up the bottom navigation with a background-image.
Here is the jQuery code for animation:
$(function() { function changeSlide( newSlide ) { // cancel any timeout clearTimeout( slideTimeout ); // change the currSlide value currSlide = newSlide; // make sure the currSlide value is not too low or high if ( currSlide > maxSlide ) currSlide = 0; else if ( currSlide < 0 ) currSlide = maxSlide; // animate the slide reel $slideReel.animate({ left : currSlide * -900 }, 400, 'swing', function() { // hide / show the arrows depending on which frame it's on if ( currSlide == 0 ) $slidePrevNav.hide(); else $slidePrevNav.show(); if ( currSlide == maxSlide ) $slideNextNav.hide(); else $slideNextNav.show(); // set new timeout if active if ( activeSlideshow ) slideTimeout = setTimeout(nextSlide, 1200); }); // animate the navigation indicator $activeNavItem.animate({ left : currSlide * 150 }, 400, 'swing'); } function nextSlide() { changeSlide( currSlide + 1 ); } // define some variables / DOM references var activeSlideshow = true, currSlide = 0, slideTimeout, $slideshow = $('#slideshow'), $slideReel = $slideshow.find('#slideshow-reel'), maxSlide = $slideReel.children().length - 1, $slidePrevNav = $slideshow.find('#slideshow-prev'), $slideNextNav = $slideshow.find('#slideshow-next'), $activeNavItem = $slideshow.find('#active-nav-item'); // set navigation click events // left arrow $slidePrevNav.click(function(ev) { ev.preventDefault(); activeSlideshow = false; changeSlide( currSlide - 1 ); }); // right arrow $slideNextNav.click(function(ev) { ev.preventDefault(); activeSlideshow = false; changeSlide( currSlide + 1 ); }); // main navigation $slideshow.find('#slideshow-nav a.nav-item').click(function(ev) { ev.preventDefault(); activeSlideshow = false; changeSlide( $(this).index() ); }); // start the animation slideTimeout = setTimeout(nextSlide, 1200); });
We've added a couple of things to our script.
First, we've included a second animation in
changeSlide()
, this time to animate the active indicator in the navigation. This animate()
is basically the same as the one we built for the reel, the main difference being that we want to move it only 150px
per slide.Finally, we added a click event listener to the items in the bottom navigation. Similar to the arrow navigation, we start by disabling the automatic animation, setting
activeSlideshow
to false
. Next, we trigger changeSlide()
, passing in the index of whichever slide was clicked, which is easy to determine using jQuery's index()
method.Now the slideshow navigation animation is complete and ready to impress your visitors.
5. Animated Icons
CSS-Tricks has a simple but elegant effect in its footer when the user mouses over various buttons. Besides the color changing and an icon being added, the effect is animated in browsers that support transition, making the icon appear to slide into place.
Let's create a similar effect, starting with some mark-up:
<a href="#" class="hover-panel"> <h3>Panel Title</h3> <p>Additional information about the panel goes in a paragraph here</p> </a>
One thing to note about this mark-up is that it has block elements nested in an
<a>
element, which makes sense semantically, but it's valid only if you're using the HTML5 doc type.Styling the Buttons
Let's set up some basic CSS to style the block in its natural (non-hovered) state:
.hover-panel { background-color: #E6E2DF; color: #B2AAA4; float: left; height: 130px; width: 262px; margin: 0 10px 10px 0; padding: 15px; } .hover-panel h3 { font-family: tandelle-1, tandelle-2, Impact, Sans-serif, sans; font-size: 38px; line-height: 1; margin: 0 0 10px; text-transform: uppercase; } .hover-panel p { font-size: 12px; width: 65%; }
Now let's add a static hover effect to change some of the colors and add a drop shadow:
.hover-panel:hover { background-color: #237ABE; } .hover-panel:hover h3 { color: #FFF; text-shadow: rgba(0, 0, 0, 0.398438) 0px 0px 4px; } .hover-panel:hover p { color: #FFF: }
Finally, let's add a background image that pops into place on hover:
.hover-panel { background-image: url(hover-panel-icon.png); background-position: 292px 10px; background-repeat: no-repeat; } .hover-panel:hover { background-position: 180px 10px; }
Here, we've added a few important styles to accomplish the hover effect. First, we've attached the background image to our
.hover-panel
. This is normally positioned outside of the button, but on mouseover, it is placed correctly. Also, note that we've placed it off to the right side of the panel, so that when we apply the transition animation, the icon will slide in from the right.Animating the Transition
Finally, let's add the transition:
.hover-panel { -moz-transition: all 0.2s ease; /* FF3.7+ */ -o-transition: all 0.2s ease; /* Opera 10.5 */ -webkit-transition: all 0.2s ease; /* Saf3.2+, Chrome */ transition: all 0.2s ease; }
The transition effect triggers the animation of the background image. Because we've flagged it to apply to
all
attributes, the transition will also be applied to the background-color
change that we applied above.Although this works in most modern browsers, it will not work in IE9. But even in unsupported browsers, the user will see the color change and icon; they just won't see the animation effect.
On most websites, this enhancement wouldn't be necessary for all users. But if support is a priority, look into this jQuery back-up.
Finally, let's bring all of the styles together:
.hover-panel { background-color: #E6E2DF; background-image: url(hover-panel-icon.png); background-position: 292px 10px; background-repeat: no-repeat; color: #B2AAA4; display: block; float: left; height: 130px; width: 262px; margin: 0 10px 10px 0; padding: 15px; -moz-transition: all 0.2s ease; /* FF3.7+ */ -o-transition: all 0.2s ease; /* Opera 10.5 */ -webkit-transition: all 0.2s ease; /* Saf3.2+, Chrome */ transition: all 0.2s ease; } .hover-panel h3 { font-family: tandelle-1, tandelle-2, Impact, Sans-serif, sans; font-size: 38px; line-height: 1; margin: 0 0 10px; text-transform: uppercase; } .hover-panel p { font-size: 12px; width: 65%; } .hover-panel:hover { background-color: #237ABE; background-position: 180px 10px; } .hover-panel:hover h3 { color: #FFF; text-shadow: rgba(0, 0, 0, 0.398438) 0px 0px 4px; } .hover-panel:hover p { color: #FFF: }
Final Thoughts
In this article, we've walked through a variety of interactive techniques that can add a bit of style and creativity to your website. Used correctly, techniques like these enhance websites, creating a more engaging and memorable user experience. But be subtle with the interactivity, ensuring that the bells and whistles do not get in the way of the website's primary function, which is to providing meaningful content.
What do you think of the techniques presented here? Do you know of any ways to improve these scripts? What are some other interactive techniques that you've seen around the Web?
(al)
© Jon Raasch for Smashing Magazine, 2011. |
Permalink |
Post a comment |
Smashing Shop |
Smashing Network |
About Us
Post tags:
"
How to Add a Free LiveChat option in your WordPress Blog
I know, this is nothing new to many Internet users because thousands of websites selling products or services are already using live chat widget to be able to talk to their potential customers. When I first experienced this couple of years ago, I was very much excited about the concept and how it works. It is a definite way of increasing sales and building trust.
For instance, a live chat with Sales and Support team of my web hosting company saved plenty of my production time. Without it, I would have spent lot of time waiting in between writing tickets, emails and then waiting for support team to respond.
Background
I have a technology blog where some of the posts feature Drupal code related information & iPhone related information. Comments to these blog posts work but, they eat up time of the visitor who sometimes are looking for a quick help than commenting on the (partially understandable) feedback again & again.
I decided to experiment with having Live Chat option for my blog. I don’t need to or cannot be online 24×7
And to my surprise, I spoke to three visitors on the first day of the experiment. I had to prolong my day at work due to ongoing conversation but it was satisfying to know they got their issues resolved & doubts cleared.
It’s been ten days in to the experiment and I spoke to ten people so far. (Not bad!)
What it has done! What it can do!
The total number of Live Chat statistics might seem less but, it must have generated confidence about my blog within those visitors to whom I spoke to. They will possibly re-visit my blog or like my Facebook page.
This system can be more useful when there are more than one author. One can always remain online to help users solve programming issues or can even make a paid service to talk to the authors.
No just that, we can also offer this to our WordPress website clients.
By using this method, I am not revealing my email ID nor adding visitors to my contact list and still be able to talk to them.
How to? Without plugin
Live Chat without plugin can be achieved using Google Talk API. This is a great service from Google and we need a Google account to use it. This service is available free for personal account as well as for Google apps account.
It shows Online or Offline status based on your logged in status of Google Talk.
I have a personal Gmail account so I will showcase using the same.
Step 1: Go to Google Talk chatback badge website to create a new badge.
Or go to this page if you have Google Apps account. (replace DOMAIN with your own domain name without http & www)
Step 2: Click ‘Edit’ to change badge settings and style. This style will be visible on our blog. If your theme supports iframe then use standard style otherwise choose styles without iframe. I have selected without an iframe.
Step 3: Google creates different badge codes every time we visit above page. We can either disable previous badges we created or add a new one. It is important to copy the following HTML code on the page. (I have blurred some of the code for security reasons.)
Step 4: Go to your blog’s Widgets admin area. Create a new text widget in sidebar & paste the above code. Click ‘Save’.
Step 5: Check how it looks on sidebar. Above code can also be used on specific articles, pages or emails you sent out.
What happens next?
If someone clicks on this chat link, s/he and we (admin/executive) get a pop-up window. We can choose to join in to the chat by clicking on a link which will create a separate chat window. Getting a separate pop-up chat window is interesting than other on-page chat boxes because it gives clarity on multiple ongoing conversations.
How does it look?
See images of how it looks when you receive a chatback from user. First a window will pop-up letting you know a chat has been initiated by your user.
Upon you clicking, it will give you a launch window.
Lastly, a chat window will open where you can chat with your users.
How to? With Plugin
Using a plugin & a Google account above is relatively simple, but if you think its difficult or you do not have a Google account or feels like having more styles, features then you can choose using a WordPress plugin.
It would be too long to describe & use screen-shots for all such plugins while all of these have different set of instructions. I am compiling a list of FREE plugins in ascending order that I liked the most. You may choose that suits your needs.
List of Free Live-Chat options for WordPress Blogs
Below is a list of different plugin or non-plugin options for adding live chat functionality to your WordPress website. Some of these use your email ID and some use Admin logged-in events to determine your Online or Offline status.
Features include:
- Multi-account fallback (when one goes offline, another available account will be used).
- Google Talk client is wrapped in a overlay widget.
- AJAX online status checking – visitors don’t need to refresh the page when you come back online.
- Customizable online and offline icons
- Customizable link for offline clicks (e.g. your contact form)
- Template tag and short-code available
- Online status caching for higher traffic volumes.
Very similar to the one which we did without the plugin with features like:
- Custom “start chat link” and “offline text”. Use text or image.
- Display things depending on if the user is online or offline
- Widget, Short-code and Template Tag support
- Translatable (send them to us if you make any)
Meebo Me is not a plugin, and it requires a free account. Interesting point is that they have iPhone and iPod application if you feel like connecting via your device.
Last Words
There are many PAID options available but I wanted to use a FREE option.
Advantage of Google or Yahoo Chat is that we would not require to login separately nor even on my blog to be able to talk to the visitors because I usually am online on gTalk most of the day time.
I hope you like this article. If you have any questions, please feel free to comment below.
How to Add a Free LiveChat option in your WordPress Blog is a post from: WPBeginner which is not allowed to be copied on other sites.
Related posts:
- Free WordPress Blog Setup
- First Official WPBeginner Chat on Twitter Tomorrow
- Increase your WordPress Blog Performance by using Google App Engine
"
How to Code a Clean Website Template in HTML5 & CSS3
Last week on MediaLoot we posted a tutorial on designing a clean homepage template using Adobe Fireworks, the result was a sleek web page concept that we’re now going to imagine that we have shown to our client, and they have just given us the go ahead to start coding it up into HTML and CSS!
Premium Members Get Source Files
Premium members can download the source files for this tutorial here.
Alright, without any further ado, let’s get started on this thing! To refresh your memory here is the design we created last week.
When it comes to coding up designs, there is a lot of personal preference, everybody has their own way of doing things, some people like to jump right in and juggle writing HTML, CSS and exporting images from the layout as needed all at the same time (this is a surprisingly common method actually), but some people break it down into stages, for example: export images, write HTML and then style with CSS, but personally I don’t think that we always know which images we will need to extract from the design until we have broken down the layout into a HTML structure. so my preferred workflow goes something like:
- Plan structure and write HTML code
- Export images from the layout
- Style the HTML with CSS
So, with that in mind, let’s begin by writing our HTML.
Preparation
Start by creating a new folder and index.html and styles.css files. Then also create a new folder called images.
Doctype and Structure
Open up the index.html file in a text editor, my preferred editor for code is MacRabbit Espresso (Mac only), for Windows try Notepad++ or Dreamweaver if needs be.
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Dreamweb</title> <link rel="stylesheet" href="styles.css" type="text/css"> <link href='http://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css'> <!--[if IE]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> </body> </html>
Begin by inserting the basic HTML skeleton, we are using HTML5 for this project so the DOCTYPE declaration is a very simple one, just “html”. You will also notice that we have set the title of the page, included our stylesheet (styles.css), included the google web font that we used in the design last week (Pacifico) and also included the html5shiv javascript snippet that will allow older browsers such as IE to understand HTML5.
Header
<header> <div class="wrapper"> <h1 class="logo"><a href="index.html">Dreamweb</a></h1> <ul> <li class="active"><a href="index.html">Home</a></li> <li><a href="#">Portfolio</a></li> <li><a href="#">About Us</a></li> <li><a href="#">Blog</a></li> </ul> </div><!--.wrapper--> </header>
Define the header tag, and then place a wrapper inside inside it so that the header can be 100% wide, but the content will be wrapped to a set width (960px), add the logo as a H1 and create an unordered list (UL) for the main menu.
Main Feature
<section class="home_feature"> <div class="wrapper"> <article class="main_display"> <img src="images/display_image_1.jpg" alt="Client Work" title="Client Work" /> <div class="display_gloss"></div> <article class="banner_new"><p>New</p></article> </article> <article class="feature_text"> <h2>Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</h2> <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat a ante venenatis dapibus posuere maecenas faucibus mollis interdum. Velit aliquet. Maecenas faucibus mollis posuere velit aliquet interdum.</p> <a href="#">Click me to find out more</a> </article> </div><!--.wrapper--> </section>
Use the same wrapper technique from the header for the main feature, we are using a <section> to contain the two <article>s in this part of layout. The feature text is quite straight forward, we have an H2, some paragraph text and a link. The main_display article will be our computer screen, and then we are layering on top of that:
- the image that will be on the screen
- followed by the gloss from the screen
- and finally the banner in the corner than reads “NEW”.
Featured Services
<ul class="featured_services"> <li class="service_1"> <Web Design&rt; <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat a ante venenatis dapibus posuere maecenas faucibus mollis interdum.</p> <a href="#" class="button_1">Find Out More</a> </li> <li class="service_2"> <Development&rt; <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat a ante venenatis dapibus posuere maecenas faucibus mollis interdum.</p> <a href="#" class="button_1">Find Out More</a> </li> <li class="service_3"> <Optimization&rt; <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat a ante venenatis dapibus posuere maecenas faucibus mollis interdum.</p> <a href="#" class="button_1">Find Out More</a> </li> </ul>
The featured services section of the layout is a very basic unordered list, we have put a different class on each list item so that it can be targeted and styled appropriately. This section doesn’t need the wrapper div because there is no defined background, we can just set the <ul&rt; to 960px wide in the CSS.
About Us and Testimonials
<div class="wrapper"> <article class="about_us_blurb"> <About Us&rt; <img src="images/about_us.png" /> <p>Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Donec sed odio dui. Aenean lacinia bibendum nulla sed consectetur. Donec ullamcorper nulla non metus auctor fringilla. Cras mattis consectetur purus sit amet fermentum. Nullam quis risus eget urna mollis ornare vel eu leo. Penatibus et magnis dis parturient montes, nascetur ridiculu.</p> <p>Donec sed odio dui. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Nulla vitae elit libero, a pharetra augue. Donec sed odio dui. Sed posuere consectetur est at lobortis. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> </article> <article class="testimonials"> <Testimonials&rt; <div class="testimonial_wrapper"> <p class="testimonial_quote"> Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Donec sed odio dui. Aenean lacinia bibendum nulla sed consectetur. </p> <p class="testimonial_name">John Doe, Company</p> </div> </article> </div><!--.wrapper-->
Here we have created 2 articles for the about us blurb and testimonials, for the testimonials we have a wrapper containing both the quote and name.
Footer
<footer> <div class="wrapper"> <!--Twitter Widget--> <div class="column"> <article class="widget_twitter"> <h4>Twitter Updates</h4> <ul> <li><strong>@MediaLoot</strong> Curabitur blandit tempus porttitor estibulum venenatis ultricies.</li> <li><strong>@MediaLoot</strong> Curabitur blandit tempus porttitor estibulum venenatis ultricies.</li> <li><strong>@MediaLoot</strong> Curabitur blandit tempus porttitor estibulum venenatis ultricies.</li> </ul> <a href="#" class="button_1">Read More</a> </article> </div> <!--Newsletter Widget--> <div class="column"> <article class="widget_newsletter"> <h4>Newsletter</h4> <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat.</p> <form> <input type="text" value="Email Address"> <input type="submit" value="Sign Up"> </form> </article> <!--Social Widget--> <article class="widget_social"> <h4>Social</h4> <ul> <li class="facebook"><a href="#">FaceBook</a></li> <li class="twitter"><a href="#">Twitter</a></li> <li class="tumblr"><a href="#">Tumblr</a></li> <li class="behance"><a href="#">Behance</a></li> <li class="linkedin"><a href="#">Linked In</a></li> </ul> </article> </div> <!--Feedback Widget--> <div class="column"> <article class="widget_feedback"> <h4>Feedback</h4> <form> <input type="text" value="Full Name" name="name"> <input type="text" value="Email Address" name="email"> <textarea name="message">Your message</textarea> <input type="submit" value="Send Message" class="button_1"> </form> </article> </div> <!--Copyright Notice--> <p class="copyright_notice">Copyright 2011 © <strong>Brand Name</strong>. All Rights Reserved.</p> <div class="logo"><p>Dreamweb</p></div> </div><!--.wrapper--> </footer><!--End Footer-->
This is quite a big one, but the actual code itself is very straight forward, each widget in the footer area has a class that begins ‘widget_’ and we have 3 <div>s with a ‘column’ class, the newsletter and social widgets are contained within the same column (as they were in the design).
Images
Let’s prepare the images we need, in total we need 17 images.
Open up the original Fireworks design file if you haven’t already and we can begin extracting the images we need. The basic method for extracting images is to select the object/s that you need, copy them and then create a new document using the clipboard dimensions (the same size as whatever you copied) and paste the objects into the new document.
1. logo.png
So open up the original Fireworks document if you haven’t already and select the Logo symbol. hit CTRL+C to copy it, CTRL+N to create a new document, and CTRL+V to paste the logo again. Set the background of the document to transparent and in the Optimize window select PNG32 as the exporting option. Go to File > Export and select Images Only and Current Page. Choose the images folder we created as the export destination.
2. hatch_pattern.png
Zoom in as far as possible on the design and use the Crop tool in Fireworks to select a 3x3px area of the pattern (as shown in the image below). Export using the same methods as used previously.
3. feature_display.png
Again follow the same method, for the display you will need to select all of the objects that make up the display excluding the banner and gloss layers.
4. display_image_1.jpg
You may need to crop the display image down if you used a clipping mask as Fireworks will use the original image’s dimensions rather than the just the clipped area that we need.
5. display_gloss.png
In the design this was set to 50% Soft Light, no web browsers support blending modes like Soft Light though to this date so it will treat it as Normal, this means we need to compensate and lower the Opacity to 20%.
6. btn_main_feature.png
Copy the button from the original design and paste it into a new document, now make the canvas 3x taller than the button, and duplicate the button one below the other so that they each occupy exactly 1/3 of the image. This is out sprite for the main button, including hover and pressed states, so the second one down is the hover state and the bottom one is pressed state.
On the hover state, nudge the top layer down 3px. On the pressed state, nudge the top layer down 1px and make the gradient slightly darker to appear pressed in.
7. service_1.png
Copy and paste the icon for your first service into a new 32x32px document.
8. service_2.png
Copy and paste the icon for your second service into a new 32x32px document.
9. service_3.png
Copy and paste the icon for yourthird service into a new 32x32px document.
10. hr_shadow.png
Same method as previously used, be sure to set the background to transparent.
11. about_us.png
Again, same method used, but we have also copied the shadow and border for this image as not all browser support advanced shadows like we created in the design.
12. social_facebook.png
13. social_facebook.png
14. social_twitter.png
15. social_tumblr.png
16. social_behance.png
17. social_linkedin.png
The CSS
First things first, open up style.css and let’s use a basic CSS reset so that all browsers, new and old are working on the same playing field.
/* CSS Reset */ body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td{margin:0;padding:0;} table{border-collapse:collapse;border-spacing:0;} fieldset,img{border:0;} ul{ list-style:none; list-style-position:outside;} a { outline: none;} /* Tell old browsers how to handle HTML5 elements */ header, footer, aside, nav, article {display: block;}
Now we will do the essential styles, these are the body, headings, paragraph, link and wrapper styles. These tend to stay the same for most web projects and are usually the first things defined in a stylesheet.
/* Essentials */ body { background: #F9FCFC; color: #666666; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; } p { line-height: 150%; } h1, h2, h3, h4, h5, h6 { font-family: Pacifico, 'Helveitca Neue', Helvetica, Arial, sans-serif; font-weight: lighter; /*counteract strong browser anti-aliasing*/ } a:link, a:visited { color: #168FAD; text-decoration: none; } .wrapper { width: 960px; margin: 0 auto; }
For the header we only really need to set the height and background, thanks to CSS3 we no longer need to use images for gradient backgrounds, we can just set the start and end points and type of gradient, even IE6 supports basic gradients with filters.
/* Header */ header { height: 110px; } header { /* Fallback Color */ background: #F4F8F9; /* Firefox 3.6+ */ background-image: -moz-linear-gradient(#FFFFFF, #E9F2F3); /* Safari 4+, Chrome 1+ */ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFFF), to(#E9F2F3)); /* Safari 5.1+, Chrome 10+ */ background-image: -webkit-linear-gradient(#FFFFFF, #E9F2F3); /* IE */ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#E9F2F3'); }
Here we are targeting the <a> link inside the <h1> with a class of ‘logo’. Note that as well as bringing in the logo.png file, we are hiding the text from visibility by setting the text-indent to -5000px. The reason for adding text and then hiding it is two-fold, it helps with your Search Engine Optimization and also boosts accessibility.
/* Logo */ h1.logo a { display: block; width: 221px; height: 65px; background: url('images/logo.png') no-repeat; float: left; margin: 20px 0 0 10px; text-indent: -5000px; }
Time to style the main navigation, we use some new CSS3 properties in this section including border-radius and box-shadow, these are both pretty much safe to use now for non-essential visual elements, in modern browsers, the vendor prefixes (i.e.. -moz-) allow you target particular browsers, -moz- for Mozzila (Firefox), -webkit- for WebKit (Safari and Chrome), but when the HTML5 and CSS3 specs are complete, vendor prefixes will not be required anymore, so for good measure include the non-prefixed version too, and put it at the end of the list so that it is applied last.
/* Main Navigation */ header ul { float: right; margin: 35px 0; } header li { float: left; display: inline-block; width: 90px; height: 36px; margin: 0 10px 0 0; } header li a { color: #2C6069; display: block; width: 90px; height: 36px; text-align: center; font-weight: bold; line-height: 36px; border: 1px solid #CDE0E4; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; -moz-box-shadow: 0 1px 0 #FFFFFF; -webkit-box-shadow: 0 1px 0 #FFFFFF; box-shadow: 0 1px 0 #FFFFFF; } header li a { /* Fallback Color */ background: #E8F4F6; /* Firefox 3.6+ */ background-image: -moz-linear-gradient(#FFFFFF, #DFF0F3); /* Safari 4+, Chrome 1+ */ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFFF), to(#DFF0F3)); /* Safari 5.1+, Chrome 10+ */ background-image: -webkit-linear-gradient(#FFFFFF, #DFF0F3); /* IE */ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#DFF0F3'); } header li a:hover { /* Fallback Color */ background: #FFFFFF; /* Firefox 3.6+ */ background-image: -moz-linear-gradient(#FFFFFF, #E8F4F6); /* Safari 4+, Chrome 1+ */ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFFF), to(#E8F4F6)); /* Safari 5.1+, Chrome 10+ */ background-image: -webkit-linear-gradient(#FFFFFF, #E8F4F6); /* IE */ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#E8F4F6'); } header li.active a { color: #5E8D94; -moz-box-shadow: inset 0 2px 3px #436E7D; -webkit-box-shadow:inset 0 2px 3px #436E7D; box-shadow: inset 0 2px 3px #436E7D; } header li.active a { /* Fallback Color */ background: #DFF0F3; /* Firefox 3.6+ */ background-image: -moz-linear-gradient(#DFF0F3, #FFFFFF); /* Safari 4+, Chrome 1+ */ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#DFF0F3), to(#FFFFFF)); /* Safari 5.1+, Chrome 10+ */ background-image: -webkit-linear-gradient(#DFF0F3, #FFFFFF); /* IE */ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#DFF0F3', endColorstr='#FFFFFF'); }
Here is the style used for the main feature, we layer up the computer screen, image on the screen, gloss from the screen and banner separately using ‘position: relative’ and ‘position:absolute’ properties.
/* Main Feature */ section.home_feature { height: 480px; background: #CDE0E4 url('images/hatch_pattern.png') repeat; -moz-box-shadow: inset 0 5px 9px #66888E; -webkit-box-shadow: inset 0 5px 9px #66888E; box-shadow: inset 0 5px 9px #66888E; } article.main_display { display: block; float: left; position: relative; width: 450px; height: 397px; margin: 70px 0; background: url('images/feature_display.png') no-repeat; } article.main_display img { position: absolute; top: 23px; left: 19px; } article.banner_new { position: absolute; left: -6px; top: -6px; background: url('images/feature_banner.png') no-repeat; width: 103px; height: 103px; } article.banner_new p { text-indent: -5000px; } article.main_display .display_gloss { position: absolute; top: 2px; right: 2px; width: 269px; height: 283px; background: url('images/display_gloss.png') no-repeat; } article.feature_text { float: right; width: 450px; margin: 60px 10px 0 0; } article.feature_text h2 { font-size: 44px; color: #2C5F66; line-height: 120%; margin: 0 0 20px 0; text-shadow: 0 1px 0 #F1F7F8; } article.feature_text p { color: #5E8C92; text-shadow: 0 1px 0 #F1F7F8; } article.feature_text a { display: block; width: 310px; height: 62px; color: #FFFFFF; background: url('images/btn_main_feature.png') no-repeat; margin: 20px 0 0 0; text-align: center; line-height: 54px; font-family: Pacifico, 'Helveitca Neue', Helvetica, Arial, sans-serif; font-weight: lighter; /*counteract strong browser anti-aliasing*/ font-size: 22px; text-shadow: 0 -1px 0 #38474A; } article.feature_text a:hover { background-position: 0 -63px; line-height: 57px; } article.feature_text a:active { color: #EFEFEF; background-position: 0 -126px; line-height: 58px; }
The featured services features the first instance of our generic button class ‘button_1’ that we will use multiple times though out the rest of the design.
/* Featured Services */ ul.featured_services { clear: both; height: 240px; width: 960px; margin: 0 auto; background: url('images/hr_shadow.png') no-repeat bottom; } ul.featured_services li { width: 300px; margin: 0 10px; float: left; } ul.featured_services h3 { font-size: 25px; color: #168FAD; text-indent: 40px; } ul.featured_services li.service_1 h3 { background: url('images/icn_service_1.png') no-repeat; background-position: 0 10px; } ul.featured_services li.service_2 h3 { background: url('images/icn_service_2.png') no-repeat; background-position: 0 10px; } ul.featured_services li.service_3 h3{ background: url('images/icn_service_3.png') no-repeat; background-position: 0 10px; } ul.featured_services p { border-left: 3px solid #CDE0E4; margin: 10px 0 10px 15px; padding: 0 0 0 25px; } .button_1 { display: block; width: 133px; height: 28px; -moz-border-radius: 50px; -webkit-border-radius: 50px; border-radius: 50px; text-align: center; line-height: 28px; border: 1px solid #ADC0C4; color: #5E8C92; font-weight: bold; font-size: 12px; cursor: pointer; } .button_1 { /* Fallback Color */ background: #DFF0F3; /* Firefox 3.6+ */ background-image: -moz-linear-gradient(#FFFFFF, #EFEFEF); /* Safari 4+, Chrome 1+ */ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFFF), to(#EFEFEF)); /* Safari 5.1+, Chrome 10+ */ background-image: -webkit-linear-gradient(#FFFFFF, #EFEFEF); /* IE */ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#EFEFEF'); } .button_1:hover { background: #FFFFFF; } .button_1:active { background: #EFEFEF; }
Styles for the About Us blurb
/* About Us Blurb */ article.about_us_blurb { clear: both; float: left; width: 620px; margin: 20px 10px; } article.about_us_blurb img { float: left; margin: 0 10px 0 0; } article.about_us_blurb h3 { font-size: 25px; color: #168FAD; margin: 10px 0; } article.about_us_blurb p { margin: 5px 20px 30px 10px; } article.testimonials { float: right; width: 300px; margin: 20px 10px; }
Styles for the testimonials
/* Testimonials */ .testimonial_wrapper { background: #E7F4F6; border: 1px solid #CDE0E4; width: 298px; height: 150px; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } article.testimonials h3 { font-size: 25px; color: #168FAD; margin: 10px 0; } p.testimonial_quote { text-align: center; background: #FFFFFF; color: #5E8C92; font-style: italic; height: 55px; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; padding: 30px 20px; } p.testimonial_name { line-height: 36px; font-weight: bold; text-align: center; color: #5E8C92; }
The footer and it’s widgets
/* Footer */ footer { clear: both; height: 400px; background: #CDE0E4 url('images/hatch_pattern.png') repeat; color: #5E8C92; } footer h4 { font-size: 25px; color: #2C5F66; margin: 0 0 10px 0; clear: both; } footer .column { float: left; display: inline_block; width: 300px; margin: 20px 10px; } /* Widgets */ article.widget_twitter li { margin: 20px 0; } article.widget_social li { float: left; display: inline_block; } footer input[type=text], footer textarea { width: 200px; height: 20px; border: none; color: #FFFFFF; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; padding: 5px 10px; margin: 10px 0; text-shadow: 0 1px 0 #0F2326; } footer input[type=text]:focus, footer textarea:focus { outline: none; } footer textarea { height: 53px; } footer input[type=text], footer textarea { /* Fallback Color */ background: #46737B; /* Firefox 3.6+ */ background-image: -moz-linear-gradient(#2C5F67, #5C858C); /* Safari 4+, Chrome 1+ */ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#2C5F67), to(#5C858C)); /* Safari 5.1+, Chrome 10+ */ background-image: -webkit-linear-gradient(#2C5F67, #5C858C); /* IE */ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#2C5F67', endColorstr='#5C858C'); } article.widget_newsletter input[type=text] { width: 130px; -moz-border-radius: 5px 0 0 5px; -webkit-border-radius: 5px 0 0 5px; border-radius: 5px 0 0 5px; float: left; } article.widget_newsletter input[type=submit] { margin: 10px 0 0 0; float: left; display: block; border: 1px solid #4E7A81; width: 70px; height: 30px; -moz-border-radius: 0 5px 5px 0; -webkit-border-radius: 0 5px 5px 0; border-radius: 0 5px 5px 0; text-align: center; line-height: 28px; border: 1px solid #ADC0C4; color: #5E8C92; font-weight: bold; font-size: 12px; cursor: pointer; } article.widget_newsletter input[type=submit] { /* Fallback Color */ background: #DFF0F3; /* Firefox 3.6+ */ background-image: -moz-linear-gradient(#FFFFFF, #EFEFEF); /* Safari 4+, Chrome 1+ */ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFFF), to(#EFEFEF)); /* Safari 5.1+, Chrome 10+ */ background-image: -webkit-linear-gradient(#FFFFFF, #EFEFEF); /* IE */ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#EFEFEF'); } article.widget_newsletter input[type=submit]:hover { background: #FFFFFF; } article.widget_newsletter input[type=submit]:active { background: #EFEFEF; }
For the social links we use one master style for the dimensions and position etc. plus an individual style for each icon setting a different background image.
/* Social Links */ article.widget_social ul li a { display: block; width: 32px; height: 32px; text-indent: -5000px; margin: 0 10px 0 0 ; } article.widget_social ul li.facebook a { background: url('images/social_facebook.png') no-repeat; } article.widget_social ul li.twitter a { background: url('images/social_twitter.png') no-repeat; } article.widget_social ul li.tumblr a { background: url('images/social_tumblr.png') no-repeat; } article.widget_social ul li.behance a { background: url('images/social_behance.png') no-repeat; } article.widget_social ul li.linkedin a { background: url('images/social_linkedin.png') no-repeat; } footer .button_1 { color: #5E8C92; }
And finally, the style for the very bottom section of the footer. The logo style is almost identical to the logo used in the header.
/* Copyright/Logo */ footer p.copyright_notice { clear: both; padding: 20px 0 0 0; } footer .logo { float: right; width: 221px; height: 65px; background: url('images/logo.png') no-repeat; margin: -40px 10px 0 0; text-indent: -5000px; }
Conclusion
And there you have it! we have successfully designed and coded a full homepage template. As always, I hope you have enjoyed reading these tutorials and perhaps gained a different perspective or even learned some new techniques. Thanks for reading!
And don’t forget that Premium members can download the source files from this tutorial.
"
5 Features of CSS3 You Can Use Today
A few days ago, the CSS 2.1 specification finally achieved W3C recommendation status. After many years of hard work, CSS 2.1 is now so well supported that upgrading the spec to recommendation status is mostly a formality. On the same day, the CSS 3 Color Module also become a recommendation. All of this is exciting news, because it means that the web is well on its way to a future filled with glorious CSS 3.
While CSS 2.1 now enjoys extremely broad interoperability, the same is not currently true for CSS 3. While the W3C and browser vendors work furiously to build our tomorrow, here are five CSS 3 features that you can start using in your sites today.
Border Radii
The border-radius property allows you to ostensibly curve the corners of an element. Previously, this was a rather tricky thing to do, involving the use of images and extra markup. Now, you can create a curved box like the one you see below.
The Code
To apply a border radius to an element, simply select the element in your CSS code and apply the border-radius property. Then, give the property an absolute or percentage value. The higher the value, the more curvy your corners will appear. To make this work in some browsers, you will need to include what are called vendor prefixes. These are necessary to protect future compatibility, should the W3C decide to change a CSS 3 property.
.myElement { /* A few vendor-prefixed versions of the property... */ -webkit-border-radius: 20px; -moz-border-radius: 20px; /* ...and the 'real' property last. */ border-radius: 20px; }
Browser Compatibility
Provided that you include the proper vendor prefixes, the border-radius property works in just about every modern browser, including Firefox, Safari, Opera, and Google Chrome. It now also works in Internet Explorer, starting with version 9. Even if the client browser doesn’t support this property, it just means that they will see squared-off corners instead of smooth curves. Remember, webpages don’t need to look exactly the same in every browser; slight cosmetic variations like this are acceptable.
New Color Models
CSS 3 comes with several new properties like border-radius, but it also comes with new units as well. CSS 2.1 offers several different ways to declare colors, such as the hexadecimal format or the named color format. Additionally, CSS 2.1 allowed colors to be specified using a special rgb() function, and CSS 3 builds upon this with rgba(), hsl(), and hsla(). While hsl() allows you to specify color using hue, saturation, and lightness (rather than red, green, and blue colors), it is the a that’s more interesting. In the rgba() and hsla() functions, the a stands for "alpha" and it allows you to adjust the opacity of the color.
The Code
To utilize one of the new color models, simply use them anywhere you might use a color. One example of this is of course the background property, which can set the background of an element to a color. To use the rgba() function, supply the red, green, and blue values, separated by commas. These should be numbers between 0 and 255, or percentages. Finally, add in the alpha value, which should be a number between 0 and 1, inclusive. The higher the number, the more opaque the color will appear, with 1 being completely opaque. These new color values do not require the use of any special vendor prefixes.
.myElement { /* A bright orange color, with some very slight transparency added. */ background: rgba(255, 128, 0, 0.7); }
The hsla() color model also takes four values. The first value is the hue, and is just an integer. The next two values are for the saturation and lightness, and these should be percentages. Finally, the alpha value functions the same as with the rgba() function, and should be a number between 0 and 1, inclusive.
.myElement { /* A solid blue color, with the transparency cut in half. */ color: hsla(240, 100%, 50%, 0.5) } }
Browser Compatibility
These new color models will work in every modern browser. Internet Explorer began supporting CSS 3 color models starting with version 9, and because colors can be more than just aesthetic enhancements, it’s important to make sure they work properly in the majority of clients. So then, what if a browser doesn’t support one of these new color models? As a fallback, you can try something like this:
.myElement { color: rgb(255, 0, 0); color: rgba(255, 0, 0, 0.9); }
Remember, the rgb() function is a part of CSS 2.1, which is already widely supported. If a browser is capable of utilizing the rgba() function, then the second declaration will override the first. If not, then the second declaration will simply be ignored. The only thing missing in this case will be the slight transparency. As I mentioned previously, slight cosmetic variations like this are acceptable.
Box Shadows
The box-shadow property makes it easy to create shadows underneath elements. Prior to CSS 3, this effect was somewhat challenging to produce and almost always required the use of images.
The Code
The box-shadow property takes four values. The first two values are the X and Y offsets, and they determine the angle of the light. The third value is the blur radius. The higher the value, the fuzzier the shadow will appear. These first three properties can be absolute or relative values. The last value is a color. Of course, you could use a hexadecimal color, but the box-shadow property is much more interesting when combined with the new color models in CSS 3. Using the rgba() color model allows the opacity of the shadow to be adjusted, making it appear as though the shadow is naturally blending with the background. Similar to the border-radius property, this property also requires the usage of vendor prefixes.
.myElement { /* A few vendor-prefixed versions of the property... */ -webkit-box-shadow: 5px 5px 5px rgba(0,0,0,0.7); -moz-box-shadow: 5px 5px 5px rgba(0,0,0,0.7); /* ...and the 'real' property last. */ box-shadow: 5px 5px 5px rgba(0,0,0,0.7); }
Browser Compatibility
As is the case with the border-radius property, this CSS 3 feature works in all modern browsers and will work in Internet Explorer 9 and up.
Fonts
Computers have been capable of displaying multiple fonts for several decades now, so it might seem odd that fonts are only just now becoming standardized on the web. However, disagreement on file formats along with complex font licensing issues have turned this into quite a difficult challenge to overcome. Fortunately, CSS 3 has put the spotlight back on web fonts, and the web is rapidly moving into a multi-font future.
The Code
Applying various fonts to blocks of text is nothing new. However, the ability to include new font faces is indeed new, where as before, we were limited to the browser defaults. To include a new font, download the font file that you’d like to include, and then use the @font-face rule to specify a name for the font along with a file path. After that, you can use the font as you normally would.
@font-face { /* Pick a name for your font. */ font-family: orbitron; /* Then, include the file path to the font file. */ src: url('orbitron-light.otf'); } .myElement { /* Finally, apply the new font to an element, with some fallbacks. */ font-family: orbitron, verdana, sans-serif; }
Browser Compatibility
This seems simple enough, and indeed, the @font-face rule works in every browser going all the way back to early versions of Internet Explorer. Including fonts isn’t quite that straightforward due to a few lingering file format compatibility issues, but fortunately, several font services have greatly simplified the process and abstracted away these problems. My favorite font service is Google Web Fonts, and I highly recommend you check it out. You can pick any fully licensed font for free, and then all you have to do is include a CSS file from Google’s fast content delivery network. Once the external CSS file has been included, the new font is available to use in other CSS documents that follow.
Opacity
With CSS 3, you can easily adjust the transparency of an element by using the opacity property. Using CSS 2.1, effects like this were tricky to achieve and in some cases, impossible.
The Code
To dial down the opacity of an element, simply apply the opacity property. Then, give it a value between 0 and 1, inclusive.
.myElement { /* This will make the element 70% opaque, or 30% transparent. */ opacity: 0.7 }
Browser Compatibility
As you might expect, this property enjoys broad support from every modern browser. opacity will work in Internet Explorer 9 and up, but to accomodate older versions of Internet Explorer, this property should be used for aesthetic enhancements only.
"