1

Can someone help me. I have this html code and i want to design my submenus with css, but i am new in this and i really need a help

<div class="nav-collapse collapse">
            <ul id="nav-list" class="nav pull-right">
                <li><a href="#home">Home</a></li>
                <li><a href="#about">About</a></li>
                <li><a href="#updates">Updates</a></li>
                <li><a href="#screenshots">Screenshots</a></li>
                <li><a href="#howto">How to</a></li>
                    <ul>
                    <li><a href="#">Sub Item 1.1</a></li>
                    <li><a href="#">Sub Item 1.2</a></li>
                    </ul>
                <li><a href="#permissions">Permissions</a></li>
                <li><a href="#download">Download</a></li>
                <li><a href="#contact">Contact</a></li>
            </ul>
        </div>

I want to have dropdown list for my submenus.My menu is horizontal at the moment

3

1 Answer 1

6

To get you started...

.nav li ul { display: none; }

.nav li:hover ul { display: block;}

Your HTML needs a minor edit also... You need to nest the sub-menu <ul> inside the parent <li>. Like below:

<li><a href="#howto">How to</a>
    <ul>
        <li><a href="#">Sub Item 1.1</a></li>
        <li><a href="#">Sub Item 1.2</a></li>
    </ul>
</li>

Here is a jsfiddle demonstrating this working, obviously it is not horizontal as I lack the styles you already made, the functionality still works however when you hover the mouse over "How To":

http://jsfiddle.net/Zuvdf/

Sign up to request clarification or add additional context in comments.

3 Comments

I apologize, I made an error by reading your code incorrectly. (its been a long day). Your HTML also isn't quite right, see my edit above for details.
Tnx about the correction above, but when i make your changes in my css, my header changes his size.How to make that submenu look like real dropdown submenu in box with borders, and the header to stay normal.I will pass my css code up in the post
here is my css jsfiddle.net/miki9999/gcpPa. I saw your link about submenus and i try to put code from this in my css , but it was different. cssmenumaker.com/menu/black-css3-drop-down-menu

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.