Raymond
Raymond

Reputation: 69

Dropdown list doesn't show up, what am i doing wrong

I'm following a tutorial on how to make a pure css drowndown menu on hover. After several times running it all over again I'm still stuck and hoping to get some good explanation on my problem.

            <div class="navbar">
                <ul>
                    <li>
                    <div><a href="3d.html">3D Printing</a></div>
                        <ul>
                            <li>
                            <div><a href="#">blah</a></div>
                            </li><li>
                            <div><a href="#">blah</a></div>
                            </li><li>
                            <div><a href="#">blah</a></div>
                            </li>
                        </ul>
                    <li>
                    <div><a href="#"></a></div>
                    </li><li>
                    <a href="#"></a>
                    </li>
                </ul>
            </div>

So this is the HTML nothing wrong with that I think.

    .navbar ul {
    position: relative;
    display: inline-block;
    font-family: lemon;
    list-style: none;
    padding: 15px 0px;
    font-size: 210%;
    margin-left: 3%;
    }
    
    .navbar ul:after {
    content: "";
    clear: both;
    display: block;
    }
    
    .navbar ul li {
    display: block;
    }
    
    .navbar ul ul {
    display: none;
    font-size: 100%;
    padding: 18px 5px;
    }
    
    navbar ul li:hover ul  {
    display: block;
    }
    
    .navbar ul ul li {
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    }
    
    .navbar ul ul li:hover {
    background: rgba(0,0,0,0.4)
    }
    
    .navbar ul li a {
    display: block;
    text-decoration: none;
    color: white;
    opacity: 0.8;
    }
    
    .navbar ul li a:hover {
    opacity: 1;
    }

The problem lies somewhere in here but I can't find it, your help is much appreciated !

Thanks in advance and my sincere greetings.

Raymond The Hammer

Upvotes: 0

Views: 46

Answers (2)

satya
satya

Reputation: 1185

Please try this:

<div class="navbar">
            <ul>
                <li>
               <a href="3d.html">3D Printing</a>
                    <ul>

                        <li><a href="#">blah</a></li>

                        <li><a href="#">blah</a></li>

                        <li><a href="#">blah</a></li>

                    </ul>
                    </li>

            </ul>
        </div>

CSS:

   .navbar ul {
    position: relative;
    display: inline-block;
    font-family: lemon;
    list-style: none;
    padding: 15px 0px;
    font-size: 210%;
    margin-left: 3%;
    }

    .navbar ul:after {
    content: "";
    clear: both;
    display: block;
    }

    .navbar ul li {
    display: block;
    }

    .navbar ul ul {
    display: none;
    font-size: 100%;
    padding: 18px 5px;
    }

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

    .navbar ul ul li {
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    }

    .navbar ul ul li:hover {
    background: rgba(0,0,0,0.4)
    }

    .navbar ul li a {
    display: block;
    text-decoration: none;
    color: black;
    opacity: 0.8;
    }

    .navbar ul li a:hover {
    opacity: 1;
    }

Upvotes: 2

Pedram
Pedram

Reputation: 16575

navbar ul li:hover ul  {
display: block;
}

you missed a dot for navbar class

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

jsFiddle

note that, do not use div inside ul li tags!

Upvotes: 1

Related Questions