2

So, I'm relatively new to HTML and CSS, and I have researched as to why my nav bar is not working plenty of times, but I can never seem to get it to work. Essentially, the items do not drop down when I hover over them, and if I change display: none; to display:block; they do not appear underneath the item either - they just drop down to the next line and display as inline. I would highly appreciate some constructive criticism so I can learn and continue to develop. Thank you ahead of time!

    html, body {
        margin: 0;
        height: 100%;
        width: 100%;
        background-color: #0E0B16;
    }
    
    #wrap {
        height: auto;
        width: 100%;
        border-bottom-style: solid;
        border-bottom-color: #E7DFDD;
        border-bottom-width: thin;
    }
    
    ul {
        padding: 0;
        margin: 0;
        text-align: justify;
        background: #0E0B16;  
    }
    
    li {
        list-style: none;
        display: inline-block;    
        text-align: left;
    }
    
    a {
        color: #E7DFDD;
        text-decoration: none;
        display: block;
        margin-left: -4px;
        padding: 16px 25px;
        font-family: Verdana;
        font-weight: bold;
        border-right-style: solid;
        border-right-color: #E7DFDD;
        border-right-width: thin;
    }
    
    a:hover {
        background-color: #E7DFDD;
        color: #0E0B16;
    }
    
    a:active {
        background-color: #E7DFDD;
        color: #0E0B16;
    }
    
    .active {
        background-color: #E7DFDD;
        color: #0E0B16;
    }
    
    .dropdown-content {
        display: none;
    }
    
    .dropdown:hover .dropdown-content{
        display: block;
    }
        <!DOCTYPE html>
    <html>
    <head>
        <title>Witcher's World</title>
        <link rel="stylesheet" href="witcher.style.css"/>
        <meta charset="UTF-8">
        
        <header>
            <nav id="wrap">
                <ul>
                    <li><a  class ="active" href="witcher.index.html">Home</a></li>
                    <li><a href="#">Witcher Lore</a></li>
                    <li><a class="dropdown" href="#">Glossary</a></li> 
                        <ul class="dropdown-content">
                            <li><a href="#">Characters</a></li>
                            <li><a href="#">Bestiary</a></li>
                        </ul>
                    <li><a class="dropdown" href="#">Weapons</a></li>
                        <ul class="dropdown-content">
                            <li><a href="#">Swords</a></li>
                                <!--<ul class="dropdown-content">
                                    <li><a href="#">Steel Swords</a></li>
                                    <li><a href="#">Silver Swords</a></li>
                                </ul-->
                            <li><a href="#">Signs</a></li>
                        </ul>
                    <li><a href="#">Books</a></li>
                </ul>
            </nav>
        </header>
    </head>
    <body>
        
        <footer>
            
        </footer>
    </body>
    </html>
   
  • What do you mean by it is not working? What output do you get? – Bunyamin Coskuner Jun 24 '17 at 21:54
  • Sorry about that - the dropdowns do not appear if I hover over them. If I take the display: none; and change it to block; they do not appear underneath the original
  • either.
  • –  Jun 24 '17 at 21:56
  • See the example of https://www.w3schools.com/css/tryit.asp?filename=trycss_dropdown_button; I think this fulfills your requirements. – jbiWeisendorf Jun 24 '17 at 22:02
  • I've been looking at this for a very long time now, but I still couldn't get it to work for me. Thank you for your suggestion, though! –  Jun 24 '17 at 22:03
  • Why you do not use a framework like bootstrap see https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_navbar_dropdown&stacked=h thats it :) – jbiWeisendorf Jun 24 '17 at 22:13