WebArtz - The Web Design Forum
Welcome to WebArtz, Guest!

WebArtz is a nice place for discussions related to web designing and coding. We help our members to code their own website templates with HTML and CSS. We give them advice on various issues.

To know more about WebArtz Forum, visit the About Us page.

At the moment, you are viewing the forum as a guest. As a guest you can't make post and participate in discussions. You need to register and become a member of the forum. Click the register link below and become a part of this forum.

Thank You

WebArtz - The Web Design Forum
Welcome to WebArtz, Guest!

WebArtz is a nice place for discussions related to web designing and coding. We help our members to code their own website templates with HTML and CSS. We give them advice on various issues.

To know more about WebArtz Forum, visit the About Us page.

At the moment, you are viewing the forum as a guest. As a guest you can't make post and participate in discussions. You need to register and become a member of the forum. Click the register link below and become a part of this forum.

Thank You


You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1Accespted Submenu using CSS Wed Jan 05, 2011 3:09 am

Guest


Guest
Submenu using CSSCreating a submenu using CSS

Hello members,

Today i am going to teach you how to create a submenu using only CSS,step by step.

Tools you may need:
+ Notepad/WYSIWYG editor/Dreamweaver/Editpad Lite/Espresso(or just an HTML editor Razz
+Basic HTML Knowlege
+Basic CSS Knowlege(since i am gonna teach you how to do the rest Razz )
+A computer
Laughing

Alright enough fun lets get working.
______________________________

Lets start with our HTML first.
We are going to create an unordered list (aka <ul>) for the whole thing,and the <span> tags to do the submenu job(we could use a mixture of onother unordered list into a list(li) but i dont really like that method)

We name our unordered list as nav:
Code:
<ul id="nav">
Now let me show you how the submenu is going to be:
Adding some links first:
Code:
<li><a href="#">Link</a></li>
 <li><a href="#">Link</a></li>
And then the submenu into the 3rd link:
Code:
<li><a href="#">Link</a>
<!--Submenu-->
<span>
            <a href="#">Subnav Link</a> |
            <a href="#">Subnav Link</a> |
        </span></li></ul>
<!--End of submenu-->

As you can see,we used the <span> tag to display the submenu and putted it into the list of the 3rd link.

Now,lets start styling the navigation using css:
I will explain everything into the css code:

Code:
ul#nav {
/**centers the navigation and we also set padding to zero(you can edit it)***/
   margin: 0; padding: 0;
/***The width of our navigation****/
        width: 900px;
/***left floating for designing just issues***/
   float: left;
/***We want the list to be displayed horizontaly***/
   list-style: none;
/***the position setup of the navigation***/
   position: relative;
/***the size of the fonts into the navigation***/
   font-size: 1.3em;
/***the color of our navigation***/
   background-color:#eaa500;
}

You can edit everything and experiment with it,you can also use an image as a background in the navigation by replacing:
Code:
background-color:orange;
with
Code:
background-image:url(imagehere.png);

Now lets work on the lists:
Code:

ul#nav li {
/****same explanation***/
   float: left;
/***same explanation***/
   margin: 0; padding: 0;
/***the divider between the links so that it looks more proffesional***/
   border-right: 1px solid black;
}
/***CSS for the links****/
ul#nav li a {
/***the padding into the navigation->space into the navigation***/
   padding: 10px 15px;
/***ideal for subnavigations***/
   display: block;
/****no underline for the navigation links-will look bad***/
   text-decoration: none;
/***the color of the navigation links***/
   color: #f0f0f0;
}

You can also add hover effects on the links of the nav,by using the selector:
Code:
ul#nav li a:hover


Now lets style the submenu:

Code:

ul#nav li span {
        width: 900px;
   background: #1376c9;
   color: #fff;
   float: left;
   padding: 15px 0;
   position: absolute
   display: none;
   left: 0; top:35px;

}
   
And other little css things so that we avoid bugs and display the submenu correctly:
Code:

ul#topnav li:hover span {
/**explained above***/
 display: block;
}
ul#topnav li span a {
/***Inline display***/
display: inline;
}
ul#topnav li span a:hover {
/****just an underline decoration****/
text-decoration: underline;
}

you will understand these,explained them in the above codes 2 times Wink

You can also use css3 rounded corners or css3 box shadows to make it look more proffesional :
-Rockerman's Box-shadow Tutorial
-Rockerman's CSS3 rounded corners tutorial

______

[url="http://rubbish.forumotion.com/h5-nav]Demo[/url] (Changed a little bit)
______

Currently,the nav wont work in IE.Searching for a script though to update it.


Notice : This tutorial is copyrighted by WebArtz Forum. You may not publish it on anywhere without written permission from the administrators.



Last edited by Nick on Fri Jan 07, 2011 2:36 am; edited 2 times in total

2Accespted Re: Submenu using CSS Wed Jan 05, 2011 4:50 am

RockerMan

RockerMan
Technician
Technician
Might wanna' provide a demo pal Wink

EDIT: Also, you might want to replace to name of the color "orange" to a hex value since it won't be valid. Here is one Smile #eaa500. There where 3 other errors too, here they are. Take a look...
Submenu using CSS Untitl10

Should always make sure you CSS and HTML is valid Smile


I updated the border-radius tut

http://www.graphics-post.com/

3Accespted Re: Submenu using CSS Wed Jan 05, 2011 2:46 pm

Guest


Guest
i know there are erros,i am trying to correct them Wink

4Accespted Re: Submenu using CSS Thu Jan 06, 2011 11:15 pm

ankillien

ankillien
Administrator
Administrator
Does this method work in IE?
Can you please add a demo to it?

5Accespted Re: Submenu using CSS Fri Jan 07, 2011 1:42 am

Guest


Guest
ankillien wrote:Does this method work in IE?
Can you please add a demo to it?

I am trying to fix the menu atm,so please bare until i update the tut and post a demo.
Sorry for any inconvenience.

EDIT:Fixed the nav,posted demo,now have to find a fix for IE(crap).

6Accespted Re: Submenu using CSS Sat Jan 15, 2011 6:26 pm

ankillien

ankillien
Administrator
Administrator
Tutorial Accepted

Sponsored content


View previous topic View next topic Back to top  Message [Page 1 of 1]

Similar topics

-

» Menu - Submenu in html?

Permissions in this forum:
You cannot reply to topics in this forum