Now, I have to be honest. I created this tutorial 2-3 years ago and I struggled with it for a long time, trying to get it right. As I went back, I spent a lot of time trying to figure out what I did in the first place and even ran into some of the same errors as I did the first time. For this navigation bar, I used HTML Dog for the main part of the tutorial and various other help forums to figure out some of the rest. While I can give good explanations for most of the tutorial, there are some parts that I don't completely understand. Also, I am not a professional web designer. Some of my modifications are probably not be the best practices for web design. But for a beginner, they get the job done.
If you don't know anything about HTML/CSS, this tutorial may be difficult for you. I have given some explanations and links that should get you through the tutorial, but if you need to make additional modifications, you may have trouble. Creative Bloq has a list of the Top 20 Online Training Resources for anyone interested in learning more about web design. I have used #1 and 10 from that list and recommend those for beginners.
For this tutorial, I created a new navigation bar, similar to the one on my blog. I am using the Blogger Simple template that was customized in my tutorial on How to Make Your Own Custom Blog Template. You can look at the actual navigation bar on my Practice Blog. Here is a preview:
Want the full tutorial? Keep reading!
Before you start the tutorial, be sure to back-up your template. Read my tutorial here on How to Back-up Your Template.
Like most web tutorials, there are two parts of code that you need to build/add to your blog, HTML and CSS. The HTML is the framework for the navigation bar and the CSS is the part that styles the navigation bar (CSS: Cascading Style Sheet)
I. HTML for Drop-Down Navigation Bar
To create your navigation bar, you need to learn a little HTML first. Navigation bars are usually made as lists. Your lists will consist of your Main Titles and your Subcategories. On my blog, my Main Titles are Home, Free Designs, Custom Designs, Tutorials, Terms of Use and About Me.The Secondary Titles are the titles that show up when you hover over these Main Titles. Under my Free Designs title, my Secondary Titles are Free Backgrounds, Free Headers and Free Templates.
In HTML terms, we are going to use unordered lists. (Go to w3schools to learn more about lists.)
The entire list of links (Main Titles and Secondary Titles) will be an unordered list that starts with <ul> and ends with </ul>.
Within the main unordered list (our entire list of links) are several list items (our Main Titles). Each list item starts with <li> and ends with </li>.
So far, your HTML would look like this:
To have Secondary Titles below these Main Titles, you have to create a new unordered list (starting with <ul> and ending with </ul>) within each Main Title. Each of these unordered lists represent the entire set of Secondary Titles for a particular Main Title. Therefore, you need to have list items (starting with <li> and ending with </li> within the Secondary unordered list. Each of these list items represent a specific Secondary Title. So adding on to the HTML above, we would have:
Add as many Secondary Titles as you need. Notice in the HTML in this last example, that the third Main Title does not have any subcategories. For any title that you do not want to have subcategories, simply close the list item with </li>.
Now, if we enter our links as shown above, the words for each title will show up but they will not be linked to anything. The HTML for links is
<a href="URL">Text</a>
You can copy the code below and modify it for your blog:
<li><a href="URL to Main Title #1">Main Title #1
<ul>
<li><a href="URL to Secondary Title #1A">Secondary #1A</a></li>
<li><a href="URL to Secondary Title #1B">Secondary #1B</a></li>
</ul>
</a></li>
<li><a href="URL to Main Title #2">Main Title #2
<ul>
<li><a href="URL to Secondary Title #2A">Secondary #2A</a></li>
<li><a href="URL to Secondary Title #2B">Secondary #2B</a></li>
</ul>
</a></li>
<li><a href="URL to Main Title #3">Main Title #3</a></li>
</ul>
This HTML needs to be added just below your header. To do this, go to your Layout page and click "Add a Gadget" and choose "HTML/JavaScript". Enter your code into the gadget and click Save.
II. CSS for Drop-Down Navigation Bar
This list so far will not look right. This kind of list will be somewhat vertical. To make it horizontal, you need to adjust it using CSS.The same navigation bar with the changes mentioned above. I also adjusted the color. |
For my blog, I used a tutorial at HTML Dog. The post is called Son of Suckerfish Dropdowns. Please read this post under the title Single-level Dropdowns to get the CSS as I am not at liberty to copy their styling in my post.
The first section in the Son of Suckerfish tutorial is pretty standard HTML that I explained in part 1 above, but the second section, the CSS styling is all theirs. I don't understand all of it but I will share with you the changes I made to accommodate my blog and why.
A. To add their CSS, go to your Template page and click "Customize" (the orange button). Click "Advanced" in the far left column. Scroll to the bottom of the second column and click "Add CSS". You can enter the CSS code from the Son of Suckerfish tutorial there. (If you already have coding there, be sure to scroll to the very bottom before adding code.)
Make sure that you copy the correct coding. You are only copying the CSS code. HTML coding starts and ends with elements in brackets, like this:
<ul>
<li>Text</li>
</ul>
CSS coding starts with a title followed by an open curly bracket and ends with a closed curly bracket:
#nav {
margin: 10px;
}
So start in the second box of their tutorial that starts with #nav... and copy the CSS from all the boxes (including the JavaScript in the second to last box) all the way until you get to Multi-level Dropdowns.
This CSS should do something similar to what you see below to your navigation bar:
My cursor was placed over the Tutorials tab to show you the drop-down menu. |
B. Clearly we need to make a few modifications. Follow along with me as I adjust the CSS. You can copy any of my changes or leave them alone depending on your preference.
First, I am going to share the simple design modifications like colors, backgrounds and fonts:
1. The CSS id #nav, #nav ul alters the entire navigation list. The "ul" refers to the large unordered list covering all the titles. (Read more about CSS "Id's and Classes" at w3schools.)
Under this id, I added a color attribute to the text. You can either add a specific color in the code or you can add a variable that will allow you to change the color in the Template Designer.
a. If you just want to add the specific color, add the following line under #nav, #nav ul {
for example:
color: #c2dbda;
*If you used variables for your colors and fonts, be sure to change them accordingly in the Template Designer.*
for example:
background: #c2dbda;
for example:
border: #5a908b solid 2px;
7. On my blog, I used my header image to create a background for my navigation bar. On Blog Designs by Dani, the blue scallop is part of my header.
On my Practice Blog the yellow ribbon is part of my header.
With the code as it is now, my navigation bar sits below this yellow ribbon.
In order to push it up onto my header and the yellow ribbon, I needed to add the following code to the id #nav, #nav ul
8. If you want to move your navigation bar to the left or the right, you can adjust the margin-left under this same id as in step 7. Add the following line to do so:
****Again, be sure to add this after "margin: 0;" or it won't work.****
Navigation bar shifted up onto the Yellow Ribbon on the Header. |
9. When I got to this point, my drop-down menus were acting weird and when I hovered over the Main Title, the drop-downs would show but would cover the Main Titles. They were sitting on top of or even above these Main Titles, instead of below them. What is even more frustrating is that different browsers will position it differently.
Drop-downs not positioned correctly |
To reset this and place them below the Main Titles, I added this line to the id #nav li:hover ul
All better...almost! |
If you add this line of code to the id #nav, #nav ul, both problems are fixed:
<Variable name="tabs.bevel.border.width" description="Tabs Bevel Border Width" type="length" default="1px" value="1px"/>
<Variable name="tabs.bevel.border.width" description="Tabs Bevel Border Width" type="length" default="1px" value="0px"/>.
*There is one more problem that I cannot figure out. When I view my Practice Blog in Internet Explorer, the drop-down menus appear on the side instead of below. They are still accessible, they just look weird. They look fine in Firefox, Chrome and Safari. If any of you figure it out, let me know!
Drop-downs sit beside the Main Titles instead of below. No idea why!? That's Internet Explorer for you, I guess. :) |
III. Creating a Header with a Navigation Bar Background
The ribbon consists of a ribbon from Katie Castillo's scrapbook kit at Just So Scrappy called "Fresh Squeezed". The ribbon was originally a scallop, but I cropped off the scalloped portion so that it was just a rectangle. I then added two more of the same ribbon and angled them so that the ribbon looked like it was wrapping around the middle of my blog. I placed the angled ribbons below the middle section as shown below:
Well, that's it! Here is the finished navigation bar or you can check out on my Practice Blog.
I can answer a few questions in the coming week or two but after that, I probably won't be checking in often. I will still allow you to post comments so that other readers may answer your questions. Good luck with your blogs!
hi dani, i tried to move my drop down list, but my background follow it.. :< how to stop the background following? just the drop down list that move?
ReplyDeleteI really dont know how to do it.. can you help me please.. i just need to combine the ribbon and the menu bar..
ReplyDeletehello, i recently opened a blog and so i need some help with the html and web design cos i dont know much about it... please can anybody help me out? i would have contracted a web designer but being only a student, i cant raise the huge amount of money i am being asked to so any help and?or tutorial i can get from this blog would be highly appreciated.
ReplyDeleteHey, great tutorial, but one little thing
ReplyDeleteIn the unordered list HTML it starts with < ul >, when it should read < ul id ="nav" > or the CSS won't work. It took me forever to figure out what was wrong!
Hopefully this help out anybody who's stuck. I love the tutorials on this site, keep up the good work
You saved me! I could NOT figure out why it wasn't working, but finally scrolled through the comments and found yours. You're a lifesaver! :)
Deletehi everyone. I am in middle of creating and design blog. And i am trying to create drop down menu. i have 2 problems.
ReplyDelete1. when i enter code at Layout page and click "Add a Gadget" and choose "HTML/JavaScript".
- all Main Titles and secondary titles appear all in one line. Which suppose to be secondary titles inside/under Main titles. Please advise.
2. next step when i go to design/templete - edit html , enter html code above the b skin command, all the code that i paste == pop up/shows at the top of my blog
Hope anyone can help me. thank you very much
An attractive looking website compels the visitors to stay for longer, and have a look at the products or services carefully. It helps reducing the bounce rate, and gaining better chances of selling online. Moreover, a web designer should be able to choose a template that matches with the business niche, and customize it excellently, as per the current trends. Reynolds Digital helped me to follow several other criterion that helped creating an awe inspiring website, and becoming a proud owner of an online shop without facing any difficulty.
ReplyDelete