html - Simple dropdown menu -


i'm trying make simple dropdown menu sub items of meme don't stay in block.

screenshot of menu

if remove float left of header li, menu of memes appears under home.

html:

<header>     <div class="container">         <div id="brand">             <h1><span class="highlight">my</span> website</h1>         </div>         <nav>             <ul>                 <li class="current"><a href="home.html">home</a></li>                 <li><a href="cv.html">curriculum vitae</a></li>                 <li><a href="pc.html">pc gaming</a></li>                 <li><a href="#">memes</a>                       <ul>                         <li><a href="#">hot</a></li>                         <li><a href="#">trending</a></li>                         <li><a href="#">upload file</a></li>                     </ul>                 </li>             </ul>         </nav>     </div>         </header>  

css:

header {     background: #35424a;     color: #fff;     padding-top: 30px;     min-height: 70px;     border-bottom: #e8491d 3px solid;    }  header {     color: #fff;     text-decoration: none;     text-transform: uppercase;     font-size: 16px; }  header li {     float: left;     display: inline;     padding: 0 20px 0 20px;   }  header #brand {     float: left; }  header #brand h1 {     margin: 0; } header nav {     float:right;     margin-top: 10px; } header .highlight, header .current {     color: #e8491d;     font-weight: bold; } header a:hover{     color: #ccc;     font-weight: bold; } nav ul li:hover ul {     display: block; }  nav ul ul {     display:none;     position: absolute; } nav ul ul li {     display: block;     background: #e8491d; } 

remove float left , change following:

header li {     position: relative;     display: inline;     padding: 0 20px 0 20px;   }  nav ul ul {     display:none;     position: absolute;     top: 100%;     left: 0; } 

demo


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -