Thursday 11 July 2013

How To Customize Multilevel Dropdown Menu ?

Customize Multilevel Dropdown Menu
In the Previous tutorial " How to create a Cool Multilevel Drop Down Menu In Blogger Template ? " i have taught you how to create it but in this tutorial i will show you how to customize it. But before explaining the tricks i want to inform you that i am dividing the code into four sections so that you can easily understand the customization process.

Also read: How to create a code box in Blogger ?
  • Now, here i am pasting the code with sections:

  <!-- Section 1 Starts -->

<script src='http://santosh143.googlecode.com/svn/dropdown.js' type='text/javascript'></script> <style>
 
 .ddsubmenustyle, .ddsubmenustyle div {
    font: normal 13px Verdana;
    margin: 0;
    padding: 0;
    position: absolute;
    left: 0;
    top: 0;
    list-style-type: none;
    background: white;
    border: 1px solid black;
    border-bottom-width: 0;
    visibility: hidden;
    z-index: 100;
}

.ddsubmenustyle ul {
    margin: 0;
    padding: 0;
    position: absolute;
    left: 0;
    top: 0;
    list-style-type: none;
    border: 0px none;
}

.ddsubmenustyle li a {
    display: block;
    width: 170px;
   /*width of menu (not including side paddings)*/
    color: black;
    background-color: lightyellow;
    text-decoration: none;
    padding: 4px 5px;
    border-bottom: 1px solid black;
}

* html .ddsubmenustyle li {
        display: inline-block;
    width: 170px;
 

}


.ddsubmenustyle li a:hover {
    background-color: black;
    color: white;
}


.downarrowpointer {
 /*CSS for "down" arrow image added to top menu items*/
    padding-left: 4px;
    border: 0;
}

.rightarrowpointer {
 /*CSS for "right" arrow image added to drop down menu items*/
    position: absolute;
    padding-top: 3px;
    left: 100px;
    border: 0;

}

.ddiframeshim {
    position: absolute;
    z-index: 500;
    background: transparent;
    border-width: 0;
    width: 0;
    height: 0;
    display: block;
}
   
<!--Section 1 Ends--> 

<!-- SECTION 2 Starts -->

  .mattblackmenu ul {
    margin: 0;
    padding: 0;
    font: bold 12px Verdana;
    list-style-type: none;
    border-bottom: 1px solid gray;
    background: #414141;
    overflow: hidden;
    width: 100%;
}


.mattblackmenu li {
    display: inline;
    margin: 0;
}


.mattblackmenu li a {
    float: left;
    display: block;
    text-decoration: none;
    margin: 0;
    padding: 6px 8px;
    border-right: 1px solid white;
    color: white;
    background: #414141;
}

.mattblackmenu li a:visited {
    color: white;
}

.mattblackmenu li a:hover {
    background: black;
      
}

.mattblackmenu a.selected {
    background: black;
}
</style>
 
 <!-- SECTION 2 Ends -->
 

<-- Section 3 Starts -->

 <div id="ddtopmenubar" class="mattblackmenu">
    <ul>
        <li>
        <a href="#">LINK1</a>
        </li>
        <li>
        <a href="#" rel="ddsubmenu1">LINK2</a>
        </li>
        <li>
        <a href="#" rel="ddsubmenu2">LINK3</a>
        </li>
        <li>
        <a href="#">Link4</a>
        </li>
        <li>
        <a href="#" rel="ddsubmenu3">LINK5</a>
        </li>
    </ul>
</div>
 
<!-- SECTION  3 Ends-->
 

<!-- SECTION 4 Starts here -->

<script type="text/javascript">
    ddlevelsmenu.setup("ddtopmenubar", "topbar") 
//ddlevelsmenu.setup("mainmenuid", "topbar|sidebar")
</script>
<ul class='ddsubmenustyle' id='ddsubmenu1'>
    <li>
        <a href='#'>LINK2 ITEM 1</a>
    </li>
    <li>
        <a href='#'>LINK2 ITEM 2</a>
        <ul>
            <li>
                <a href='#'>LINK2 ITEM 2.1</a>
            </li>
            <li>
                <a href='#'>LINK2 ITEM 2.2</a>
            </li>
        </ul>
    </li>
    <li>
        <a href='#'>LINK2 ITEM 3</a>
        <ul>
            <li>
                <a href='#'>LINK2 ITEM 3.1</a>
            </li>
        </ul>
    </li>
    <li>
        <a href='#'>LINK2 ITEM 4</a>
    </li>
</ul>
<ul class='ddsubmenustyle' id='ddsubmenu2'>
    <li>
        <a href='#'>LINK3 ITEM 1</a>
    </li>
    <li>
        <a href='#'>LINK3 ITEM 2</a>
    </li>
    <li>
        <a href='#'>LINK3 ITEM 3</a>
        <ul>
            <li>
                <a href='#'>LINK3 ITEM 3.1</a>
            </li>
        </ul>
    </li>
    <li>
        <a href='#'>LINK3 ITEM 4</a>
    </li>
    <li>
        <a href='#'>LINK3 ITEM 5</a>
        <ul>
            <li>
                <a href='#'>LINK3 ITEM 5.1</a>
            </li>
            <li>
                <a href='#'>LINK3 ITEM 5.2</a>
                <ul>
                    <li>
                        <a href='#'>LINK3 ITEM 5.2 1</a>
                    </li>  
               </ul>
            </li>
        </ul>
    </li>
    <li>
        <a href='#'>LINK3 ITEM 6</a>
    </li>
</ul>
<ul class='ddsubmenustyle' id='ddsubmenu3'>
    <li>
        <a href='#'>LINK5 ITEM 1</a>
    </li>
</ul>
  
<!-- Section 4 ENDS--> 
  • Section 1 Customizations: This section is generally meant for the sub menu's items as shown below in screenshot also for customization see the screenshots below.

    •  Red   : You can change the font size as per your requirements given in Pixels.
    • Orange  : You can change the font style of your sub menu items for eg. Lucida Handwriting, Arial etc.
    • Green   : Here you can change the background color of your sub menu item, here you can use color names or you can use HTML color codes like #414141 etc.
    • Blue    : Here you can change colors and this color appears whenever you hover your mouse over it.
    • Pink   : Never change it
  • Section 2 Customizations: This section is generally meant for the Main Menu. 
    • Red   : Here you can change the font type of your main menu i.e. Bold, italic etc.
    • Green   : Here you can change the font size given in Pixels.
    • Blue   : Here you can change the font style as mentioned in section 1's orange.
    • Pink   : To change the background color of your Menu bar you have to change the two color codes shown in pink colors.
    • Orange : You can change the color here for hover i.e. whenever somebody hover his/her mouse over the tab then it changes color to your specified color.
    • Purple   : Here you can change color and this color appear when somebody selects a particular tab in menu bar.
  • Section 3 Customizations: This section is generally for putting your links and titles in the main menu.
    • Red   : Here you can replace the '#' with your page URL.
    • Green   : Here you can replace the text with your TEXT.
  • Section 4 Customization: This is also for putting your links and text but in the sub menu and also the menu inside the menu i.e. nested menu or you can say that sub sub menu.
    • Red   : Replace the '#' with your link.
    • Green   : Replace the given text with your text. 
     
This is it from my side for any queries please comment below or contact me via Contact Page.

Also read:

10 comments:

  1. Hi there,
    Any idea who to get rid of that weird spacing between my page tab and the dropdown list?
    my website: http://www.pingerrain.com

    ReplyDelete
    Replies
    1. 1. for spacing in drop down menu :
      search this line in the above code( mainly in section 2) "padding: 6px 8px;"
      and replace the value 8 with 0 or 1 as per your requirements.
      After changing your code will look like "padding: 6px 0px;"
      this will sort out your problem of wierd spacing.

      2. for your tabs spacing problem go to template>> edit html
      then search this code :

      /* Tabs
      ----------------------------------------------- */
      .tabs-inner .section:first-child {
      border-top: $(header.bottom.border.size) solid $(tabs.border.color);
      }

      .tabs-inner .section:first-child ul {
      margin-top: -$(header.border.size);
      border-top: $(header.border.size) solid $(tabs.border.color);
      border-left: $(header.border.horizontalsize) solid $(tabs.border.color);
      border-right: $(header.border.horizontalsize) solid $(tabs.border.color);
      }

      .tabs-inner .widget ul {
      background: $(tabs.background.color) $(tabs.background.gradient) repeat-x scroll 0 -800px;
      _background-image: none;
      border-bottom: $(tabs.border.width) solid $(tabs.border.color);

      margin-top: $(tabs.margin.top);
      margin-left: -$(tabs.margin.side);
      margin-right: -$(tabs.margin.side);
      }

      .tabs-inner .widget li a {
      display: inline-block;

      padding: .6em 1em;

      font: $(tabs.font);
      color: $(tabs.text.color);

      border-$startSide: $(tabs.border.width) solid $(content.background.color);
      border-$endSide: $(tabs.bevel.border.width) solid $(tabs.border.color);
      }

      .tabs-inner .widget li:first-child a {
      border-$startSide: none;
      }

      .tabs-inner .widget li.selected a, .tabs-inner .widget li a:hover {
      color: $(tabs.selected.text.color);
      background-color: $(tabs.selected.background.color);
      text-decoration: none;
      }

      /* Columns
      ----------------------------------------------- */

      and then search this line in above code : padding: .6em 1em;
      now replace 1 with 0 or 0.1 ,0.2 or any thing as per your requirement .
      after changing it will look like:

      padding: .6em 0em;


      some other customizations :

      1. if you want to change the box size of dropdown list then search this code :

      .ddsubmenustyle li a {
      display: block;
      width: 170px;

      and change the value of width from 170 to 100 or more as per you needs.

      2. if you want to reduce the spacing between text and red drop arrow then search the following code :

      /*CSS for "down" arrow image added to top menu items*/
      padding-left: 4px;
      border: 0;
      }

      and change the padding value from 4 to 0 or 1 or someother.

      i hope this will help you


      Delete
    2. I've tried it. Not the correct one.
      It's that weird space between the 2 widgets..
      The pages tab (Home About My Travels) and the dropdown list widget

      ----
      Now it's like this:

      Home About My Travels My Art, Crafts & DIYs My Stories My Bucket List Contact


      California Connecticut Florida Hawaii New York Flights Chronicles Cruise Chronicles Travel Tips
      ------

      I want it like this:

      Home About My Travels My Art, Crafts & DIYs My Stories My Bucket List Contact
      California Connecticut Florida Hawaii New York Flights Chronicles Cruise Chronicles Travel Tips

      Delete
    3. for reducing the space between gadgets ..
      first go to template>> customize>> Advance >> Add CSS
      Then paste the below code in it and click enter then save it.

      .widget {

      margin: 5px 0 0 0;
      }

      i hope this will help you , you can change the pixel value 5 to more or less as per your requirement

      Delete
    4. Thanks very much!
      Didn't really help cause it just bring down the space of all widgets instead of 1.
      However, I did learn a lot!
      Thanks again!

      Delete
    5. finally i have found a solution of your problem,
      just go to template>> customize>> advanced >> add css

      and paste the below code in add css box, click enter and then save it


      .tabs-inner .widget {text-align:center; margin:5px 0;}

      i hope this time it will solve your problem, i have also pasted a copy of this comment on your blog.

      happy blogging ..!

      Delete
    6. Hihi~
      thanks very much! It works!
      However, the code couldn't be pasted inside the Add CSS section (the apply to blog is grey out).

      I added it in the html/javascript widget that held my dropdown list instead and it works beautifully.

      Thank you so so so much!!

      Delete
    7. i am really happy to see that your problem is resolved ..... :)

      keep visiting (o) and happy blogging cheer

      Delete
  2. How do you change the font color on the main buttons?

    ReplyDelete