html - How to Make a Dropdown In a Navbar Using CSS? -


the problem having dropdown does'nt display on hover.

please can tell me how can make dropdown using css.
have following code:

html:

<nav>     <ul class="navbar">         <li><a href="#home">home</a></li>         <li><a href="#news">news</a></li>             <ul>                 <li><a href="#home">home</a></li>                 <li><a href="#news">news</a></li>             </ul>         <li><a href="#contact">contact</a></li>         <li><a href="#about">about</a></li>     </ul> </nav> 

css:

.navbar > ul  {     display: none; }  .navbar > li:hover > ul {     display: block;  }  ul .navbar {     list-style-type:none;     overflow:hidden; }  .navbar > li  {     color: white;     text-decoration: none;     font-family: 'comic sans ms'; }  .navbar > li {     background: -webkit-linear-gradient(gray,black);     width: 100px;     display: block;     position: relative;     float: left;     text-align:center;     padding-top: 18px;     padding-bottom: 18px;     padding-left: 25px;     padding-right: 25px; }  .navbar > li:hover {     cursor: pointer;     background: gray; } 

jsfiddle:

http://jsfiddle.net/ay5l6/

change nested list structure. move closing li tag of item news after sub ul list below.

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

change below

<li><a href="#news">news</a>             <ul>                 <li><a href="#home">home</a></li>                 <li><a href="#news">news</a></li>             </ul> </li> 

also make below css change

.navbar > ul  {     display: none; } 

change above this

.navbar ul  {   display: none; } 

demo


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -