Beginners Easy Steps of Css Menu Design:
There are lot of tutorial for menu design in web but all are so complex. After searching for the appropriate tutorial of Css Menu design
for beginners I started myself to write Css Menu design for beginners.
On a web page, the navigation can be taken as a table of content.
In HTML, table of content can be represent by the element. ol stands for ordered list.
The code to making a simple ordered list:
The above code will result:
1. Chapter 1
2. Chapter 2
3. Chapter 3
If we want to link an item the Table of content will look like below:
The HTML above shows that we want an ordered list of chapters that contain links to other sections of a site.
We can see that a couple of the elements above have some attributes set. The attributes the class and id.
The class attribute should be considered as metadata for the element it is applied to. For example, one of the list chapter has the class=” current”.
This means us that one chapter is currently selected. The id attribute uniquely identifies a particular element.
The content Text… ldquo;-//W3C//DTD XHTML 1.0 Strict//EN” Text… That’s right, we’ll only be dealing with one image. It doesn’t matter if we have five different states for the tab, it can all be done with one image. I’ll start by answering the obvious question: Why? Each image has a header section. The filesize of six small images would be about twice as big as the filesize of one big image. Each state will take up one row of the image and will be 500 pixels wide. The idea is that the left side of the tab will be drawn in one element, then the rest will be drawn on top of it in a child element. I will explain how in the next step. Each row is 60 pixels high. This will allow the tab to be up to 60 pixels high, but it can be smaller. Now, you might be worried. Worried about the “500 pixel” bit of my previous paragraph. Don’t be, though. We will be saving this rather big image as a GIF image, which in my case took it down to just a couple of kilobytes. If you know that you will never have tabs even close to 500 pixels wide, you can of course shrink it. Even 200 pixels might be enough. But thanks to compression, the difference probably won’t be more than a few bytes.
Save this image where you saved chapter The first thing we’ll do is to style the ordered list that represents our Table Of Content ( ldquo;-//W3C//DTD XHTML 1.0 Strict//EN” Text… Do this for Chapter2.html Text... Text...
Content is generally made up of one or more headers, some paragraphs with text and every now and then some other stuff such as images, lists, quotes etc.
We’ll want to encapsulate the content so that we can put other things outside it without having trouble identifying it later on.
A
We’ll give it an identifying class, because there might be other
Page 1
Now we put together the Table of content and content :
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
For the file to validate, it needs a document type. The document type specifies what rules the document must follow for it to be valid. I usually go with XHTML 1.0 Strict,
but there are other document types that are more… forgiving. I won’t be covering them in this tutorial.
The tag holds metadata about the document. In this particular case, it holds the character encoding of the page, so that the browser doesn’t have to guess.
The element is used for linking to external resources, in this case a stylesheet. We’ll be making the stylesheet.
My Frist Menu Design
Page 1
Splitting the image into pieces left, middle and right requires six separate images for two states. If we were to add another state, for example a hover effect, the number of images required would increase to nine. Other than extra file management and more work when editing the images, what does this mean?
Each image requires its own HTTP request. This wastes both bandwidth and server processing time.
Due to the images being requested separately this also means that the page will take longer to load, especially if the user’s browser downloads the files one by one.
There is no way to apply the method I’m going to describe using three images for one tab, since each tab consists of only two elements (
Hopefully I’ve convinced you that putting everything into one image is much better than using several images. Moving on…
1.html
, or make your own image. Name it tabs.gif
.The tabs
):
ol#menu {
height: 2em;
list-style: none;
margin: 0;
padding: 0;
}
Stle of Default State of each Chapter:
ol#menu li {
background: #bdf url(tabs.gif);
float: left;
margin: 0 1px 0 0;
padding-left: 10px;
}
Style for the link:
ol#menu a {
background: url(tabs.gif) 100% 0;
color: #008;
float: left;
line-height: 2em;
padding-right: 10px;
text-decoration: none;
}
Style for the current :
ol#menu li.current {
background-color: #48f;
background-position: 0 -60px;
}
Style for the current menu link
ol#menu li.current a {
background-position: 100% -60px;
color: #fff;
font-weight: bold;
}
Style for The content :
div.content {
border: #48f solid 3px;
clear: left;
padding: 1em;
}
All are together will look like this:
ol#menu {
height: 2em;
list-style: none;
margin: 0;
padding: 0;
}
ol#menu li {
background: #bdf url(tabs.gif);
float: left;
margin: 0 1px 0 0;
padding-left: 10px;
}
ol#menu a {
background: url(tabs.gif) 100% 0;
color: #008;
display: block;
float: left;
height: 2em;
line-height: 2em;
padding-right: 10px;
text-decoration: none;
}
ol#menu li.current {
background-color: #48f;
background-position: 0 -60px;
}
ol#menu li.current a {
background-position: 100% -60px;
color: #fff;
font-weight: bold;
}
div.content {
border: #48f solid 3px;
clear: left;
padding: 1em;
}
And hence the end of the tutorial.
If you want to test the above created menu then follow the steps:
Step 1:
Make a folder named menu:
Step 2:
make three blank html files in it:
Chapter1.html
Chapter2.html
Chapter3.html
Style.css
To make html file open text editor :
file ->save->save as type->choose all file ->file name->type filename.html->ok
in case of Style.css file type style.css in file name instade of html
step 3:
Right click on Chapter1.html ->open with->notepad
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
My Homepage
Page 2
My Homepage
Page 2
Do this for Chapter3.html
My Homepage
Page 2
For Style.css
ol#menu {
height: 2em;
list-style: none;
margin: 0;
padding: 0;
}
ol#menu li {
background: #bdf url(tabs.gif);
float: left;
margin: 0 1px 0 0;
padding-left: 10px;
}
ol#menu a {
background: url(tabs.gif) 100% 0;
color: #008;
display: block;
float: left;
height: 2em;
line-height: 2em;
padding-right: 10px;
text-decoration: none;
}
ol#menu li.current {
background-color: #48f;
background-position: 0 -60px;
}
ol#menu li.current a {
background-position: 100% -60px;
color: #fff;
font-weight: bold;
}
div.content {
border: #48f solid 3px;
clear: left;
padding: 1em;
}
Save the above images as tabs.gif
One Response to “Beginners Easy Steps of Css Menu Design:”
Leave a Reply
Recent Post
Popular Post
- Coolmath's Games To Math and Thinking (1930 views)
- List of world's famous Books and Authors (1032 views)
- Top Tourist Places in India (827 views)
- C Tutorial For The Beginners With Example And Source Code (656 views)
- Best 10 Hill Stations in India (548 views)
- Microsoft Surface Pro tablet with Windows 8 will redefine the computing industry (538 views)
- How Can Hackers Help In The Fight Against Cancer? (482 views)
- 5 Best Beaches Between Mumbai And Goa In India (474 views)
- A NASA Scientist Answers the Top 20 Questions About 2012 (446 views)
- The Mayan Mysteries And End Of World In 21 December 2012 (382 views)
July 12th, 2012 at 2:18 pm
Excellent items from you, man. I have bear in mind your stuff previous to and you’re just too great. I actually like what you have acquired here, certainly like what you are stating and the best way in which you say it. You make it entertaining and you still care for to keep it wise. I cant wait to learn far more from you. That is actually a terrific web site.