Archive for June, 2010

What is jScrollPane?

jScrollPane is a jQuery Plugin that gives you the liberty to replace the browsers default “Vertical Scrollbars” with your own customized ones. This means that if you dont want the browsers default vertical scrollbars to appear on a webpage, then you can create your own customized scrollbars, and use it in place of browsers default vertical scrollbars with the help of this plugin.

With the use of this jQuery Plugin, you can easily control the apperance of the custom scrollbars using simple CSS.

Step 7: Now we need a vertical scrollbar (which can then be replaced with a customized Vertical Scrollbar). To create a vertical scrollbar, write the following code between <body> and </body> tags of index.html.

By assigning these styles, you will find that the vertical scrollbar appears on the page.

What are we doing here ?

First, we created 2 boxes. we named them “container” and “content“.
“Content” box goes inside the “Container” box. This we have already seen and understood.

Now lets see what we are doing in the styling part. We are giving a fixed height (300px) and width (400px) to the container box. Just remember one thing that the scroll bar will appear on the container box.

To the content box we are giving a width (350px) which is less than the container box. We are doing this to avoid the appearence of horizontal scroll bar on the container box. Instead we are giving a height (1000px) to the content box, because we want the vertical scroll bar to appear on container box.

After all this is done, just assign a property “overflow: auto” to the container box, which will make the vertical scrollbar appear on your web page. Please see the figure below for clear understanding.

Step 12: That’s it. We are done. Just save your html file, and see your customized vertical scrollbar in action. Now you can edit the jScrollPane.css file to customize it as per your requirement. Click here to see the demo of jScrollpane. For a complete list of options and detailed description, please visit the jScrollPane homepage.

What are browser Compatibility issues?

I will try to explain it in the simplest possible way. Suppose you make any website and it looks perfectly alright in your default browser. Now you try opening the same website in some different browser, and you see some difference in its appearance. You again open the same website in a third browser and it again looks a bit different (as compared to the other two browsers). Now you start wondering, how to make the website appear same in all the browsers.

Yes.. You are now dealing with browser compatibility issues. It is the most common problem that every web-designer goes through. Every Website Developer / Designer spends most of his/ her time struggling to solve browser compatibility issues.

What Causes Browser Display Differences?

Different Browsers

Different Browser Versions

Different Computer Types

Different Screen Sizes

Different Font Sizes

HTML Errors

Browser Bugs

For a detailed description on each of the above listed topics, please visit this link.

How to solve browser Compatibility issues?

There are a set of rules and regulations that you need to follow in order to make your website look consistent across all the browsers, like using a correct DOC type, Validating your HTML and CSS etc. But here I am not going to discuss about all these rules.

Today I am going to share two major utilities with you which will solve almost all your browser compatibility issues. They are:

Reset CSS

CSS Browser Selector javascript

Reset CSS

Normally every browser assigns some default styles (like default line heights, margins, paddings, and font sizes, headings, and so on) to HTML elements. Because of this default styling adapted by the browsers, every html document appears to be a bit different in different browsers.

The use of Reset CSS file removes and neutralizes the inconsistent default styling of HTML elements, creating a levelled baseline across all major browsers and providing a sound foundation upon which you can explicitly declare your styles.

There are many reset style-sheets available on the internet today. You can find a good collection of different reset CSS files here. You can download and use any reset CSS stylesheet depending on your choice and requirement. Alternatively you can download my choice of reset CSS as a separate stylesheet; or copy and paste the following stylesheet code on top of your default stylesheet.

Lets assume a situation that you have created a webpage with font size of 16px.This web page appears to be the same in all the browsers, but in safari browser, you feel that the font size appears to be a bit bigger. To solve this issue, you can include the CSS Browser selector javascript between your <head> and </head> tags like this:

After this, you can define the style rules for safari browser like this which will solve your issue.

.safari body{
font-size: 15px;
}

As you can see the code above that we have defined a seperate class “.safari” for the safari browser. In the same way you can define the class “.ie” for Internet Explorer, and “.opera” for Opera browser. Following list shows you all the possible browser codes which you can use as classes for that particular browser.

ie — Internet Explorer

ie8 — Internet Explorer 8.x

ie7 — Internet Explorer 7.x

ie6 — Internet Explorer 6.x

ie5 — Internet Explorer 5.x

gecko — Mozilla, Firefox (all versions), Camino

ff2 — Firefox 2

ff3 — Firefox 3

opera — Opera (All versions)

opera8 — Opera 8.x

opera9 — Opera 9.x

opera10 — Opera 10.x

konqueror — Konqueror

webkit — Safari, NetNewsWire, OmniWeb, Shiira, Google Chrome

safari — Safari, NetNewsWire, OmniWeb, Shiira

safarii3 — Safari 3.x

chrome — Google Chrome

Similar to this you can specify the class for different operating systems also. Following list shows you all the possible operating system codes which you can use as classes for that particular operating system.

win — Microsoft Windows

linux — Linux (x11 and linux)

mac — Mac OS

freebsd — FreeBSD

ipod — iPod Touch

iphone — iPhone

webtv — WebTV

mobile — J2ME Devices (ex: Opera mini)

For getting more information on CSS Browser Selector javascript, go to its homepage. To download Browser selector javascript click here

Step 9: Write the following line of code between the <body> and </body> tag of “index.html” to create a link.

<a href="#" id="test-link">Click Me</a>

Step 10: Write the following lines of code between the <body> and </body> tag of “index.html” to create some test content that can be displayed in the popup when the link is clicked.

<div id="test-content">
<h1>Test Heading</h1>
<p>
This is just a test content that does not make any sense. This is just a test content that does not make any sense. This is just a test content that does not make any sense. This is just a test content that does not make any sense. This is just a test content that does not make any sense.
</p>
</div>

Step 10: Now wrap the content div inside <div style=”display: none”> and </div>. By doing this we are wrapping our content inside a hidden div so that our content is not visible. It is because we want the content to be displayed only on clicking a link. Now our code inside the <body> and </body> should look something like this.

<a href="#" id="test-link">Click Me</a>
<div style="display: none;">
<div id="test-content">
<h1>Test Heading</h1>
<p>
This is just a test content that does not make any sense. This is just a test content that does not make any sense. This is just a test content that does not make any sense. This is just a test content that does not make any sense. This is just a test content that does not make any sense.
</p>
</div>
</div>

Step 11: Now write the following line of code between <head> and </head> tag to bring the colorbox in action.

Step 12: That’s it. We are done. Just save your html file, and click on the link to see the colorbox popup in action.

The best part about colorbox is that it is extremely light weight. It is less than 9kb in size and is highly customizable. You can change anything and everything from appearence to functionality. You can also use a lot of options with it. For a complete list of options and detailed description, please visit the Colorbox homepage.