HTML dropdown menu with links on the left -


i have following code, , works fine, except "contact" link needs last link. however, dropdown seems placed last?

it navbar @ http://www.w3schools.com/css/tryit.asp?filename=trycss_dropdown_navbar want create, 2 additional links after dropdown link.

<!doctype html> <html> <head> <style> ul {     list-style-type: none;     margin: 0;     padding: 0;     overflow: hidden;     background-color: #333;     float:right; }  li {     float: left; }  li a, .dropbtn {     display: inline-block;     color: white;     text-align: center;     padding: 14px 16px;     text-decoration: none; }  li a:hover, .dropdown:hover .dropbtn {     background-color: #111; }  .dropdown {     display: inline-block; }  .dropdown-content {     display: none;     position: absolute;     background-color: #f9f9f9;     min-width: 160px;     box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); }  .dropdown-content {     color: black;     padding: 12px 16px;     text-decoration: none;     display: block; }  .dropdown-content a:hover {background-color: #f1f1f1}  .dropdown:hover .dropdown-content {     display: block; } </style> </head> <body>  <ul>   <li><a class="active" href="#home">home</a></li>   <li><a href="#news">news</a></li>   <div class="dropdown">     <a href="#" class="dropbtn">dropdown</a>     <div class="dropdown-content">       <a href="#">link 1</a>       <a href="#">link 2</a>       <a href="#">link 3</a>     </div>   </div> <li><a href="#products">products</a></li> <li><a href="#contact">contact</a></li> </ul>    </body> </html> 

it not render correctly, i'm not sure how change css accomplish this. or perhaps there way?

thanks

try changing tag of dropdown div li. browser renders li first , div.

<li class="dropdown">   <a href="#" class="dropbtn">dropdown</a>   <div class="dropdown-content">     <a href="#">link 1</a>     <a href="#">link 2</a>     <a href="#">link 3</a>   </div> </li> 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -