Posts Tagged ‘Cascading Style Sheets’

In this post I want to explain How To Implement Live Content Preview with jQuery. This is very basic jquery tutorial using keyup() element. It’s useful just five lines of javascript code to show live content preview. Best examples Google Adwords Campaign piece preview. Take a look at live demo

Download Script

Contains javascipt code. $(“.word”).keyup(function(){}word is the class name of anchor input field. Using $(this).val() calling input field value.

// <![CDATA[
javascript” src=”
// ]]>
<script type=”text/javascript”>




var word=$(this).val();

return false;


HTML code

<input type=”text” name=”word”color: blue;”>word” /><spancolor: blue;”>word_preview“></span>



font-family:Arial, Helvetica, sans-serif;




width:150px; height:26px; font-size:18px;


I received lot of requests from my readers that asked to me how to implement Pagination with jQuery, PHP and MySQL. so I had developed a simple tutorial. It’s looks big but very simple script. Take a look at this live demo
Pagination with jQuery, MySQL and PHP.

The tutorial contains three PHP files and two js files includes jQuery plugin.

-config.php (Database Configuration)

Download Script     Live Preview

Database Table

message TEXT

Contains javascript this script works like a data controller.


//Display Loading Image

function Display_Load()
$(“#loading”).html(“<img src=”bigLoader.gif” />”);

//Hide Loading Image

function Hide_Load()

//Default Starting Page Results

$(“#pagination li:first”)
.css({‘color’ : ‘#FF0084’}).css({‘border’ : ‘none’});
$(“#content”).load(“pagination_data.php?page=1”, Hide_Load());

//Pagination Click

$(“#pagination li”).click(function(){

//CSS Styles

$(“#pagination li”)
.css({‘border’ : ‘solid #dddddd 1px’})
.css({‘color’ : ‘#0063DC’});

.css({‘color’ : ‘#FF0084’})
.css({‘border’ : ‘none’});

//Loading Data

var pageNum =;
$(“#content”).load(“pagination_data.php?page=” + pageNum, Hide_Load());


You have to change hostname, username, password and databasename.


$mysql_hostname = “localhost”;
$mysql_user = “username”;
$mysql_password = “password”;
$mysql_database = “database”;
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password)
or die(“Opps some thing went wrong”);
mysql_select_db($mysql_database, $bd)
or die(“Opps some thing went wrong”);


User interface page.


$per_page = 9;

//Calculating no of pages
$sql = “select * from messages”;
$result = mysql_query($sql);
$count = mysql_num_rows($result);
$pages = ceil($count/$per_page)


// <![CDATA[
javascript” src=”
// ]]>
// <![CDATA[
javascript” src=”jquery_pagination.js”>
// ]]>

<div id=”loading” ></div>
<div id=”content” ></div>
<ul id=”pagination”>
//Pagination Numbers

for($i=1; $i<=$pages; $i++)
echo ‘<li id=”‘.$i.‘”>’.$i.‘</li>’;


Simple php script display data from the messages table.


$per_page = 9;

$start = ($page-1)*$per_page;
$sql = “select * from messages order by msg_id limit $start,$per_page”;
$result = mysql_query($sql);


<table width=”800px”>


while($row = mysql_fetch_array($result))


<td><?php echo $msg_id; ?></td>
<td><?php echo $message; ?></td>





CSS Code
CSS code for page numbers.


width: 100%;
position: absolute;


list-style: none;
float: left;
margin-right: 16px;
border:solid 1px #dddddd;


cursor: pointer;


Send money for FREE

Pasting anything other than simple text into the browser has historically been stupendously impossible. Until now… It’s a miracle, image data pasted into the browser can be retrieved with JavaScript (at least since Chrome 13.0.782.220)! Just use this jQuery plugin and start receiving paste events with images all their sweet gooey image data. This picks up paste events initiated with Ctrl+V, it does not provide arbitrary clipboard access (which is probably sane from a security standpoint). What’s insane is that it used to be so hard to get pasted image data, but that is all behind us now.A magical wizardCopy and paste me in this webpage!Give it a try now, right click this wizard and choose “Copy Image”, then jam Ctrl+V or Command+V. Be amazed (unless you’re not using Chrome, and in that case, get off my lawn). It also works in the pixel editor on

PixieEngine. Use the wizard there too, the editor currently only handles small images. Generally there is no size restriction, you can even paste image data from your favorite image editing programs, boot one up and try it out on this page.

# Created by STRd6
# MIT License
(($) ->
  $.event.fix = ((originalFix) ->
    (event) ->
      event = originalFix.apply(this, arguments)

      if event.type.indexOf('copy') == 0 || event.type.indexOf('paste') == 0
        event.clipboardData = event.originalEvent.clipboardData

      return event


  defaults =
    callback: $.noop
    matchType: /image.*/

  $.fn.pasteImageReader = (options) ->
    if typeof options == "function"
      options =
        callback: options

    options = $.extend({}, defaults, options)

    this.each ->
      element = this
      $this = $(this)

      $this.bind 'paste', (event) ->
        found = false
        clipboardData = event.clipboardData clipboardData.types, (type, i) ->
          return if found

          if type.match(options.matchType) or clipboardData.items[i].type.match(options.matchType)
            file = clipboardData.items[i].getAsFile()

            reader = new FileReader()

            reader.onload = (evt) ->
                event: evt
                file: file


            found = true


Pretty simple plugin, eh? The first part is extending the copy and paste events in jQuery with the clipboardData object. Once the paste events have been extended with all the clipboard data that Chrome provides we can use that data to extract the image contents.

The meat of the plugin is binding a paste event to all the elements in the selector. When a paste event is triggered we loop through each MIME type until we hit one that claims to be an image. Once we find it we get the corresponding file data and load it as a dataURL. This can be used directly in CSS or passed on to the server and chopped up, base64 decoded, and stored as a regular png.

To use it you choose what element to listen to paste events on (html should get all of them). I haven’t messed around much with scoping it to other elements, but I don’t see why it wouldn’t work.

$("html").pasteImageReader (results) ->
  {filename, dataURL} = results  $("body").css
    backgroundImage: "url(#{dataURL})"

Now when someone pastes a copied image to the page it sets the background to the pasted image. This is just scratching the surface, but the great thing is that you can now capture paste events containing images in pure JS/HTML.

What’s that? CoffeeScript is hot for you to handle? Well here’s the JS version:

// Created by STRd6
// MIT License
// jquery.paste_image_reader.js
(function($) {
  var defaults;
  $.event.fix = (function(originalFix) {
    return function(event) {
      event = originalFix.apply(this, arguments);
      if (event.type.indexOf('copy') === 0 || event.type.indexOf('paste') === 0) {
        event.clipboardData = event.originalEvent.clipboardData;
      return event;
  defaults = {
    callback: $.noop,
    matchType: /image.*/
  return $.fn.pasteImageReader = function(options) {
    if (typeof options === "function") {
      options = {
        callback: options
    options = $.extend({}, defaults, options);
    return this.each(function() {
      var $this, element;
      element = this;
      $this = $(this);
      return $this.bind('paste', function(event) {
        var clipboardData, found;
        found = false;
        clipboardData = event.clipboardData;
        return, function(type, i) {
          var file, reader;
          if (found) {
          if (type.match(options.matchType) || clipboardData.items[i].type.match(options.matchType)) {
            file = clipboardData.items[i].getAsFile();
            reader = new FileReader();
            reader.onload = function(evt) {
              return, {
                event: evt,
                file: file,
            return found = true;

Java (programming language)

One of the great things about the Veracode platform is the insight we get from examining our anonymized customer data – not only information about the vulnerability landscape (as published in the State of Software Security report) but insight into the composition of the applications that we scan. As I alluded in my last post, one of the things we record when scanning applications is the presence of frameworks and other supporting technologies, and we’ve been at work mining that data to understand what developers use to build their applications. We’d like to share some of that research with you today.

How does Veracode look for the presence of frameworks in Java code? Because our customers upload the application packages that they deploy or distribute (as EARs, WARs, or JARs), we can observe the presence of framework classes, configuration files, and other artifacts in the application. We record the prevalence of the framework so that we can mine the anonymized data later. We resample the data every few months to get an idea of relative framework prevalence and to see if any trends can be observed.

Below is our most current Top 10 list for Java frameworks. This list is based on a sample of over 5400 customer applications and was sampled on December 7, 2011. Note that we have decomposed one of the larger framework families, Spring, into its component frameworks to get a better idea of the usage of its individual parts. The percentages reflect the number of Java applications (not individual scans) in which the framework was observed, so an application that was scanned multiple times only counts once in the rankings.

  1. Spring MVC (23%)
  2. Struts 1.x (15%)
  3. Apache Axis (15%)
  4. Apache Xerces (14%)
  5. Hibernate (12%)
  6. JDOM (12%)
  7. Java Applet (8.1%)
  8. Apache Velocity (7.9%)
  9. Apache ORO (7.0%)
  10. JAX-WS (6.5%)

A couple of interesting findings here. First, the relative prevalence of Spring MVC and Struts is unsurprising, but the fact that Struts 1.x is #2 on the list and Struts 2 is not even in the Top 10 is a little surprising. (It came in 24th in the overall rankings, in fact, showing up in just 1.8% of the Java applications scanned).

Second, it’s interesting to note that there are multiple frameworks for web services in the top ten, and that Axis appears to have an edge on popularity over JAX-WS.

Third, the relatively high number of applications scanned that contained Java applets was interesting. It’s hard to imagine that 8% of all Java applications have a customer facing applet. One is tempted to speculate that in many cases these applets are administrative interfaces to framework or server code that are left in the application distribution inadvertently or unknowingly, and thus that these represent potentially forgotten attack surfaces for the application.

We’re just starting to mine the data that we’re seeing regarding frameworks. I think that this data should be interesting to development teams looking to choose frameworks that are more widely used. From a security perspective, too, this is a useful reminder that applications rely on third party frameworks, and that some of these may come with their own attack surface (e.g. applets) that shouldn’t be forgotten when planning secure deployments.

Written by:

Web sites have changed since the appearance of HTML5 and CSS3 and also after the latest jQuery releases. They now have interesting features which make them more dynamic and also easy to load and navigate because most of the graphics that were previously jpeg, gif or png files are now mostly done in code. Most of the sites in this article are making use of these new technologies and that can be seen easily when navigating. It’s a pleasure to see wonderful sites like for which people worked carefully and with a clear strategy. - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You - Awesome New Website Designs To Inspire You

  1. // Function to check letters and numbers
  2. function alphanumeric(inputtxt)
  3. {
  4.  var letterNumber = /^[0-9a-zA-Z]+$/;
  5.  if((inputtxt.value.match(letterNumber))
  6.   {
  7.    return true;
  8.   }
  9. else
  10.   {
  11.    alert(“message”);
  12.    return false;
  13.   }
  14.   }

To get a string contains only letters and numbers (i.e. a-z, A-Z or 0-9) we use a regular expression /^[0-9a-zA-Z]+$/ which allows only letters and numbers. Next the match() method of string object is used to match the said regular expression against the input value. Here is the complete web document.


  1. <!–DOCTYPE html>
  2. <html lang=”en”>
  3. <head>
  4. <meta charset=”utf-8″>
  5. form validation – checking all letters and numbers

  6. css’ type=’text/css’ />
  7. </head>
  8. <body onload=’document.form1.text1.focus()’>
  9. <div class=”mail”>
  10. <h2>Enter your Registration Number and Submit</h2>
  11. <form name=”form1″ action=”#”>
  12. <ul>
  13. <input type=’text’ name=’text1’/>
  14. rq”>*Enter numbers and alphabets only.
  15. &nbsp;
  16. <input type=”submit” name=”submit” value=”Submit” onclick=”alphanumeric(document.form1.text1)” />
  17. &nbsp;
  18. </ul>
  19. </form>
  20. </div>
  21. <script src=”check-letters-numbers.js”></script>
  22. </body>
  23. </html>

Javascript code

  1. function alphanumeric(inputtxt)
  2. {
  3. var letters = /^[0-9a-zA-Z]+$/;
  4. if(inputtxt.value.match(letters))
  5. {
  6. alert(‘Your registration number have accepted : you can try another’);
  7. document.form1.text1.focus();
  8. return true;
  9. }
  10. else
  11. {
  12. alert(‘Please input alphanumeric characters only’);
  13. return false;
  14. }
  15. }

CSS Code

  1. li {list-style-type: none;
  2. font-size: 16pt;
  3. }
  4. .mail {
  5. margin: auto;
  6. padding-top: 10px;
  7. padding-bottom: 10px;
  8. width: 400px;
  9. background : #D8F1F8;
  10. border: 1px soild silver;
  11. }
  12. .mail h2 {
  13. margin-left: 38px;
  14. }
  15. input {
  16. font-size: 20pt;
  17. }
  18. input:focus, textarea:focus{
  19. background-color: lightyellow;
  20. }
  21. input submit {
  22. font-size: 12pt;
  23. }
  24. .rq {
  25. color: #FF0000;
  26. font-size: 10pt;
  27. }



English: example of a data table with rollup f...


This tag is used to create table on the page. The component is rendered as an html element. UIColumn child components are responsible for rendering columns of the table. In these columns you can put any type of component like input text box, output text, command button etc.

<h:column> tag is used to create column. There can be many column tags within dataTable tag. You can set header and footer in this table. For this <f:facet> tag is used. data table component and its children column component can use header and footer facet.



We can associate this table element to backing bean. So we can obtain data from this backing bean and display it on the table. Association of backing bean can also be helpful for event handling purpose. Suppose we inserted command button in columns of the table then event handling can be applied here. If you want to customize the table then cascading stylesheet (CSS) can be used. This will help you to enhance the appearance of the table’s headers, footer, rows, columns.


This section provides you the code to which uses this tag and some of its attributes. It uses backing bean that supplies data to the data table to be rendered to the cells of the columns of the table.

code description :


<%@ taglib uri="" prefix="h"%>
<%@ taglib uri="" prefix="f"%>

<h:dataTable id="dt1" value="#{TableBean.perInfoAll}" var="item" bgcolor="#F1F1F1" border="10" cellpadding="5" cellspacing="3" first="0" rows="4" width="50%" dir="LTR" frame="hsides" rules="all" summary="This is a JSF code to create dataTable." >

<f:facet name="header">
<h:outputText value="This is 'dataTable' demo" />

<f:facet name="header">
<h:outputText value="id" />
<h:outputText value="#{}"></h:outputText>

<f:facet name="header">
<h:outputText value="name"/>
<h:outputText value="#{}"></h:outputText>

<f:facet name="header">
<h:outputText value="phone"/>
<h:outputText value="#{}"></h:outputText>

<f:facet name="header">
<h:outputText value="city"/>
<h:outputText value="#{}"></h:outputText>

<f:facet name="header">
<h:outputText value="pin"/>
<h:outputText value="#{}"></h:outputText>

<f:facet name="footer">
"The End" />




Rendered Output :


In this example we have used <h:dataTable> tag. This <h:dataTable> tag has many attributes to give form and shape to the table and getting data from backing bean’s attribute to display this data to the columns of the table. <f:facet> tag is used to create a header and a
footer for a dataTable component and it can create the same for columns also. So in this example we have used facet tag in dataTabe tag to create header and footer of the table component and in column tag also to create header for column. In this example, “This is ‘dataTable’ demo” is the header and “The End” is the footer for the table and “id” “name” “phone” “city” “pin” are headers for columns. In his example we have populated data to the table from bean named “TableBean”. It contains an attribute “perInfoAll” that is an array of objects of type “perInfo” class which contains some attributes like id, name, phone, city, pin that is to be displayed on the table. In the value attribute of dataTable tag, we have specified the binding expression to bind this component to the bean (
value="#{TableBean.perInfoAll}") and value specified in var attribute is used to populate data to the column of the table from attributes defined in class perInfo (value="#{}"). The code for the bean has been given below (remember to specify it in faces-cocfig.xml file) :


public class TableBean {

private perInfo[] perInfoAll = new perInfo[]{
new perInfo(101, "CHANDAN", "9891444444", "aaa", 11111),
new perInfo(102, "RAVI", "9911666666", "bbb" ,22222),
new perInfo(103, "JOHN", "9313888888", "ccc", 33333),
new perInfo(104, "ANDREW", "9911222222", "ddd" , 44444),
new perInfo(105, "SYMONDS", "9313999999", "eee", 55555),

public perInfo[] getperInfoAll() {
return perInfoAll;

public class perInfo {
int id;
String name;
String phone;
String city;
int pin;

public perInfo(int id, String name, String phone, String city, int pin) { = id; = name; = phone; = city; pin;

public int getid() {
return id;

public String getname() {
return name;

public String getphone() {
return phone;

public String getcity() {
return city;

public int getpin() {
return pin;




HTML Source Code:


          <form id="_id0" method="post" action="/dt/data.jsf;jsessionid
=B95AF7B5F7D80BCB5638B91AC8154C33" enctype="application/x-www-form-urlencoded">
		<table id="_id0:dt1" bgcolor="#F1F1F1" border="10"
 cellpadding="5" cellspacing="3" dir="LTR" frame="hsides" rules="all"
 summary="This is a JSF code to create dataTable." width="50%">
                       <tr><th colspan="5" scope="colgroup">This is
 'dataTable' demo</th></tr>
                          <th scope="col">id</th>
                          <th scope="col">name</th>
                          <th scope="col">phone</th>
                          <th scope="col">city</th>
                          <th scope="col">pin</th>
                       <tr><td colspan="5">The End</td></tr>
		<input type="hidden" name="_id0" value="_id0" />


This tag has some attributes. These are listed below :


  • id : This is used to uniquely identify the table component. This must be unique within the closest parent component.
  • value : It represents the value of the component. It represents the value over which iteration is to be done. It may be an array or any iterator object .
  • var : This is the name of the variable created by the data table that represents the current item in the value. This attribute helps exposing the data in the rows of the table.
  • bgcolor : This attribute is used to set the background color for the table.
  • border : We can set the width of the table’s border around the table.
  • cellpadding : This sets the space between the content and the border of the cell.
  • cellspacing : It specifies the amount of space to leave between cells.
  • first : This is used to specify the row number of the first row from which displaying is to be started onwards. Suppose, this property is set to 3,displaying will be started from the third row of the underlying data.
  • rows : This attribute specifies the number of rows to display. This displaying will be started from the index specified in the “first” attribute. If we set this attribute to zero then all rows will be displayed.
  • width : This is used to set the width of the entire table. Its value is specified in %. Suppose we set it to 50% then this table will be shown in the 50% space of the width of your screen.
  • dir : This attribute indicates the direction of the text to be displayed in the cell. It takes “LTR” (left-to-right) and “RTL” (right-to-left) values. If we don’t specify this attribute then the content will be displayed in center.
  • frame : This attribute specifyes which sides of the frame surrounding this table will be visible. This attribute can take some values shown below :


  1. none  No side, Default Value
  2. above  Top side only
  3. below  Bottom side only
  4. hsides   Top and bottom sides only
  5. vsides   Right and left sides only
  6. lhs   Left hand side only
  7. rhs  Right hand side only
  8. box   All four sides 
  9. border  All four sides


  • rules : This attribute is used to draw lines between cells. It can take some values given below :
    1. none   No rules, default value
    2. groups  Between row groups
    3. rows   Between rows only
    4. cols  Between columns only
    5. all   Between all rows and columns
  • summary : You can specify summary of the purpose of the table.
  • rendered : It takes boolean value.This indicates whether or not this component should be rendered. Its default value is “true”. If it is set to false then it prevents rendering of this component to the page.
  • captionClass : Space separated list of CSS class or classes that will be applied to any caption generated for this table.
  • captionStyle : It specifies CSS style or styles to be applied when this caption is rendered.
  • columnClasses : Comma seperated list of CSS classes that will be applied to the columns of this table.
  • footerClass : This attribute takes Space-separated list of CSS style class or classes that will be applied to aheaderter generated for this table.
  • headerClass : This attribute takes Space-separated list of CSS style class or classes that will be
    applied to any header generated for this table.
  • rowClasses : It is a list of CSS classes applied to the rows of the table.These classes should be separated by comma. If we want to apply CSS class for individual rows then we can specify space separated list of CSS classes. Style classes are applied to rows in the same order that they are
    defined. If we have two CSS classes then first class is applied to the first row and the second one is applied to the second. Then again in the third row, the first CSS is applied and so on. This process goes on till the last row of the table. 
  • lang :  It sets the base language of an element?s attributes and text i.e. the language used in the generated markup for this component.
  • styleClass : It sets the name of CSS classor classes that is applied at the time of rendering the element.
  • title : The title attribute is used to set the tooltip text to display for the rendered  component.Tooltip describes an element when rendered to the client. 
  • binding : It is a value binding expression that is used to link component to a property in a backing bean.
  • onclick : It sets the JavaScript code to execute when a pointer button is clicked over this element.
  • ondblclick : It sets the JavaScript code to execute when a pointer button is double clicked over this element.
  • onkeydown : It sets the JavaScript code to execute when a key is pressed down over this element.
  • onkeypress : It sets the JavaScript code to execute when a key is pressed and released over this element.
  • onkeyup : It sets the JavaScript code to execute when a key is released over this element.
  • onmousedown : It sets the JavaScript code to execute when a pointer button is pressed down over this element.
  • onmousemove : It sets the JavaScript code to execute when a pointer button is moved within this element.
  • onmouseout : It sets the JavaScript code to execute when a pointer button is moved away from this element.
  • onmouseover : It sets the JavaScript code to execute when a pointer button is moved onto this element.
  • onmouseup : It sets the JavaScript code to execute when a pointer button is released over this element.




Just about every website uses the regular navigation concepts we’re all used to. After awhile this can get pretty boring, especially for designers who thrive on creativity. While mimicking the OS X dock and stacks isn’t new, it’s certainly not common.

A few days ago, Jeffrey posted about a potential “outside the box” competition on ThemeForest to encourage authors to put on their creativity hats and design usable templates with “outside the box” creative designs. In this tutorial I’ll cover a few ways to do just that with OS X style docks and stacks navigation.
Sources and Credits

Before we get started, I want to give a shout out to a couple guys who came to the rescue when they heard my call for help on Twitter. Steve updated the stacks script by Harley from using jQuery 1.2.6 to use the current 1.3.2 release and Rey Bango from the jQuery team helped me fix a bug. They both jumped to the task within a couple minutes of my cry for help via Twitter. Thanks a ton guys! *Round of applause* 😀

Original Sources
“Adding to Our Leopard Desktop with jQuery” by Harley via
Interface: Fisheye Menu
jqDock v1.2
Example template (Internet Encyclopedia) by Luka Cvrk
Quick Notes

These scripts rely on jQuery 1.3.2. The examples shown are compatible with all major browsers including IE6 and are easy to ensure graceful degrading if JavaScript is off or disabled.
jQuery OS X Dock #1 (Horizontal)

The first dock we’ll build uses the jQuery Fisheye Menu plugin mentioned above. It’s pretty lightweight (~7kb with dependencies) but the main reason I wanted to use this one was because it’s incredibly smooth, no stuttering. View Demo.

As you can see in the demo, it’s incredibly smooth and responsive. The downside is that you can’t use fixed positioning with it if the page needs to scroll as it will break. If you don’t need it fixed within the browser window then it works great.

This is a great example of “outside the box” concepts in websites and provides an interactive and fun interface.

Required files (I’ve combined the Fisheye plugin and iutil.js in the demo files).
jQuery 1.3.2
Interface: Fisheye Menu plugin
Interface: iutil.js (dependency)

We’ll wrap our images and titles in links and place them within a containing div. Then we’ll wrap it all in another containing div for it to function properly.
view plaincopy to clipboardprint?
<div id=”dock”>
<a href=”index.html”><span>Example 1</span><img src=”; alt=”home”></a>
<a href=”example2.html”><span>Example 2</span><img src=”; alt=”contact”></a>
<a href=”example3.html”><span>Example 3</span><img src=”; alt=”portfolio”></a>
<a href=”all-examples.html”><span>All Examples</span><img src=”; alt=”music”></a>
<a href=””><span>Video</span><img src=”; alt=”video”></a>
<a href=””><span>History</span><img src=”; alt=”history”></a>
<a href=””><span>Calendar</span><img src=”; alt=”calendar”></a>
<a href=””><span>Links</span><img src=”; alt=”links”></a>
<a href=””><span>RSS2</span><img src=”; alt=”rss”></a>

<!– end div .dock-container –>

<!– end div .dock #dock –>

Notice that I’ve placed the titles in span tags so we can style them as well as allow the plugin to hide/show them as necessary.

With CSS we’ll position the dock where we want it on the page. We can’t use fixed positioning with this plugin or it won’t function properly.
.dock-container { position: relative; top: -8px; height: 50px; padding-left: 20px; }
a.dock-item { display: block; width: 50px; position: absolute; bottom: 0; text-align: center; text-decoration: none; color: #333; }
.dock-item span { display: none; padding-left: 20px; }
.dock-item img { border: 0; margin: 5px 10px 0px; width: 100%; }

I’ve also placed a little extra CSS in the head of the page below the CSS included above. I wrapped it in noscript tags in case a visitor doesn’t have JavaScript enabled or available, it will still be a usable navigation. I should point out that this will not validate because the noscript tag isn’t valid in the head section, even though it works in all the current browsers. 😉
#dock { top: -32px; }
a.dock-item { position: relative; float: left; margin-right: 10px; }
.dock-item span { display: block; }
The JavaScript

We’ll bring in our JavaScript files now starting with jQuery 1.3.2. The fisheye-iutil.min.js file is the combination of the Fisheye plugin and its dependent iutil.js file. We’ll create the last file and put our JavaScript necessary to initialize the dock in it.
view plaincopy to clipboardprint?
<script type=”text/javascript” src=””></script&gt;
<script type=”text/javascript” src=”js/fisheye-iutil.min.js”></script>

Now we’ll initialize the dock once the page loads. You can use several plugin options to customize the dock as you need for positioning and functionality. You can view the documentation by visiting the site listed under sources for the Fisheye plugin.
view plaincopy to clipboardprint?
$(function () {
// Dock initialize
maxWidth: 30,
items: ‘a’,
itemsText: ‘span’,
container: ‘.dock-container’,
itemWidth: 50,
proximity: 60,
alignment : ‘left’,
valign: ‘bottom’,
halign : ‘center’

That’s all there is to it! 😀

jQuery OS X Dock #2 (Vertical)

The horizontal dock was easy and definitely a neat idea to use on websites. They’re probably the most common type used across the web currently so let’s try something different. We could get a little more “outside the box” if we did a vertical dock navigation.

This dock relies on the jqDock jQuery plugin. It’s approximately 10kb in size, so it’s a few kb larger than the previous version but that’s not much. The disadvantage to this plugin is that it’s not quite as smooth as the Fisheye plugin dock, although it’s still very fluid and certainly usable. This plugin also doesn’t have issues with fixed positioning. View Demo.

We’ll put our images in an unordered list and wrap them in links. As with the last plugin, we’ll wrap everything within a containing div. When we initialize the plugin we’ll use the “ul” here.
view plaincopy to clipboardprint?
<div id=”dockContainer”>
<ul id=”jqDock”>
<li><a href=”index.html”><img src=”; alt=”Home” title=”Example 1″></a></li>
<li><a href=”example2.html”><img src=”; alt=”Contact” title=”Example 2″></a></li>
<li><a href=”example3.html”><img src=”; alt=”portfolio” title=”Example 3″></a></li>
<li><a href=”all-examples.html”><img src=”; alt=”music” title=”All Examples”></a></li>
<li><a href=””><img src=”; alt=”video” title=”Video”></a></li>
<li><a href=””><img src=”; alt=”history” title=”History”></a></li>
<li><a href=””><img src=”; alt=”calendar” title=”Calendar”></a></li>
<li><a href=””><img src=”; alt=”links” title=”Links”></a></li>
<li><a href=””><img src=”; alt=”rss” title=”RSS”></a></li>
<li><a href=””><img src=”; alt=”rss” title=”RSS”></a></li>

<!– end div #dockContainer –>

You’ll notice on this dock we don’t have titles wrapped in span tags. Instead, this plugin will look at the “title” tag set for each image and create the titles that way (if enabled in the plugin options). This makes the markup a little simpler but it also makes the titles a little less customizable.

We position the dock on the left side (can be either side) using fixed positioning. We’ll give it a little space between itself and the top of the browser window for aesthetics and so the icons don’t disappear when enlarged.
#dockContainer { position: fixed; top: 60px; left: 6px; }
#jqDock { position: relative; bottom: 48px; }
.jqDockLabel { background: #333; color: #fff; padding: 3px 10px; -webkit-border-radius: 10px; -moz-border-radius: 10px; }

To style the titles we can use the “.jqDockLabel” class. We also won’t need to include any extra styles for it to still be usable with JavaScript disabled. It may not be very pretty but it’s functional.
The JavaScript

We’ll bring in the jQuery library just like the previous dock as well as the plugin.
view plaincopy to clipboardprint?
<script type=”text/javascript” src=”js/jquery.jqDock.min.js”></script>

We initialize the dock and set a few options to customize it. You can read the documentation on these settings by visiting the site listed under sources at the beginning of the tutorial for jqDock. What I want to point out here though is the duration option. This is the time for magnification animation in milliseconds. It’s nice to be able to change the duration speed but it seems to get a little stuttery, which is something I hate.
view plaincopy to clipboardprint?
var jqDockOpts = {align: ‘left’, duration: 200, labels: ‘tc’, size: 48, distance: 85};

You can easily change the positioning of the dock and labels as well as the initial size of the icons and a few other options. What I didn’t like about this plugin is that it magnifies to the full size of the icon. The previous plugin gives you the ability to change the size it magnifies to. That’s all there is to it!

jQuery OS X Stack and Drop Stack

This is probably my favorite navigation style out of the three shown in this tutorial. It’s super lightweight (~1kb) and is a really creative “outside the box” method of navigation for a website. It might be a little awkward having the navigation in the bottom right or left of the browser window but it would certainly be creative and save lots of space. View Demo.

While writing this, I realized there are probably many people that won’t like their navigation at the bottom of the page so I took a couple extra minutes and added a drop-down stack to the example files. This way the navigation springs out from top to bottom so it can now be used at the top of pages.
View Demo.

The HTML is just as simple as the two dock examples. We’ll place everything in a containing div and place all our images and titles, which are wrapped in links, within an unordered list.
view plaincopy to clipboardprint?
<img src=”; alt=”stack”>
<ul id=”stack”>
<li><a href=””><span>Aperture</span><img src=”; alt=”Aperature”></a></li>
<li><a href=””><span>All Examples</span><img src=”; alt=”Photoshop”></a></li>
<li><a href=”example3.html”><span>Example 3</span><img src=”; alt=”Safari”></a></li>
<li><a href=”example2.html”><span>Example 2</span><img src=”; alt=”Coda”></a></li>
<li><a href=”index.html”><span>Example 1</span><img src=”; alt=”Finder”></a></li>

<!– end div .stack –>

Notice that I’ve placed an image before the unordered list. This is the basket image that the rest of the icons will be stacked behind.

We’ll position the main container and make sure the basket image has a higher z-index than the unordered list so everything stacks behind it. Also notice that I’ve given the basket image 35px of padding. This prevents the icons behind the basket from being clicked since the basket image is shorter than the icons. If you change the basket icon to something taller then you’ll need to also change the padding.
view plaincopy to clipboardprint?
.stack { position: fixed; bottom: 28px; right: 40px; }
.stack > img { position: relative; cursor: pointer; padding-top: 35px; z-index: 2; }
.stack ul { list-style: none; position: absolute; top: 5px; cursor: pointer; z-index: 1; }
.stack ul li { position: absolute; }
.stack ul li img { border: 0; }
.stack ul li span { display: none; }
.stack .openStack li span {
font-family: “Lucida Grande”, Lucida, Verdana, sans-serif;
height: 14px;
top: 17px;
line-height: 14px;
border: 0;
padding: 3px 10px;
border-radius: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
color: #fcfcfc;
text-align: center;
text-shadow: #000 1px 1px 1px;
opacity: .85;
filter: alpha(opacity = 85);

/* IE Fixes */
.stack { _position: absolute; }
.stack ul { _z-index:-1; _top:-15px; }
.stack ul li { *right:5px; }

The titles wrapped in span tags are set to display:none so they’ll be hidden when the page loads.
The JavaScript

We’ll place the JavaScript in its own file since it’s more than a couple lines. When the image outside the unordered list (the basket) is clicked, it uses jQuery’s toggle function to animate the the list items and set their position based on the horizontal starting point + .75px then multiplied by 2. This gives us the nice curved spring action of the list items.

You could change the .75px or the multiplier (2) to customize how much it curves.
view plaincopy to clipboardprint?
$(function () {
// Stack initialize
var openspeed = 300;
var closespeed = 300;
var vertical = 0;
var horizontal = 0;
var $el=$(this);
$(this).animate({top: ‘-‘ + vertical + ‘px’, left: horizontal + ‘px’}, openspeed);
vertical = vertical + 55;
horizontal = (horizontal+.75)*2;
${top: ‘-50px’, left: ’10px’}, openspeed).addClass(‘openStack’)
.find(‘li a>img’).animate({width: ’50px’, marginLeft: ‘9px’}, openspeed);
$el.animate({paddingTop: ‘0’});
}, function(){
//reverse above
var $el=$(this);
$‘openStack’).children(‘li’).animate({top: ’55px’, left: ‘-10px’}, closespeed);
$‘li a>img’).animate({width: ’79px’, marginLeft: ‘0’}, closespeed);
$el.animate({paddingTop: ’35’});

// Stacks additional animation
$(‘.stack li a’).hover(function(){
$(“img”,this).animate({width: ’56px’}, 100);
$(“span”,this).animate({marginRight: ’30px’});
$(“img”,this).animate({width: ’50px’}, 100);
$(“span”,this).animate({marginRight: ‘0’});

Then when the user clicks the basket image again it runs the next function which reverses what we just did. I then added some additional animation to the list items and their titles to give them a little more user feedback, which of course can easily be removed.

And there you have it! A simple and flexible OS X style stack navigation for your website. 😀 This script is also in the process of being converted into an easier to use plugin so keep an eye out for that.

Simple and modern looking black menu template, horizontal dropdown web navigation. I will make and share more color skins in one of next posts. Customizable width size, current width of the menu is 950px (to change it edit 5th row in CSS file). If you have an average CSS knowledge, it will be easy to understand and update any detail in CSS code.

Check also two more web navigations in PSD format – website navigation menus set and horizontal HTML & CSS navigation.

horizontal dropdown menu





File Size (ZIP): 5 KB

Full size – JPG preview: Black dropdown menu

Format: HTML and CSS

Color theme: black, gray

Keywords: download horizontal menu template, black web navigation, web design elements, make your own web navigation

Author: PSD Graphics

Download HTML and CSS source: