I need make a wordpress menu with css only (dropdown style menu)
i can't find the correct way maybe the error its on the classes assigned but i already try some options and none fix the problem, with this code i can see the menu but never display the items and subitems would be great some help
This is the wordpress tag and codes and also the css used
************************************
MENU
************************************
<label for="show-menu" class="show-menu">Show Menu</label>
<input type="checkbox" id="show-menu" role="button">
<nav id="superior">
<?php wp_nav_menu(
array(
'container'=> false,
'items_wrap' => '<ul id="%1$s" class="%2$s nav nav-pills"> %3$s</ul>',
'theme_location' => 'menu'
)); ?>
</nav>
************************************
.CSS
************************************
/*Strip the ul of padding and list styling*/
ul {
list-style-type:none;
margin:0;
padding:0;
position: absolute;
}
/*Create a horizontal list with spacing*/
li {
display:inline-block;
float: left;
margin-right: 1px;
}
/*Style for menu links*/
li a {
display:block;
min-width:140px;
height: 50px;
text-align: center;
line-height: 50px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #fff;
background: #2f3036;
text-decoration: none;
}
/*Hover state for top level links*/
li:hover a {
background: #c3c3c3;
}
/*Style for dropdown links*/
ul li:hover ul a {
background: #f3f3f3;
color: #2f3036;
height: 40px;
line-height: 40px;
}
/*Hover state for dropdown links*/
li:hover ul a:hover {
background: #19c589;
color: #fff;
}
/*Hide dropdown links until they are needed*/
ul li ul {
display: none;
}
/*Make dropdown links vertical*/
ul li ul li {
display: block;
float: none;
}
/*Prevent text wrapping*/
li ul li a {
width: auto;
min-width: 100px;
padding: 0 20px;
}
/*Display the dropdown on hover*/
ul li a:hover + .hidden, .hidden:hover {
display: block;
}
/*Style 'show menu' label button and hide it by default*/
.show-menu {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
text-decoration: none;
color: #fff;
background: #19c589;
text-align: center;
padding: 10px 0;
display: none;
}
/*Hide checkbox*/
input[type=checkbox]{
display: none;
}
/*Show menu when invisible checkbox is checked*/
input[type=checkbox]:checked ~ #menu{
display: block;
}
/*Responsive Styles*/
@media screen and (max-width : 760px){
/*Make dropdown links appear inline*/
ul {
position: static;
display: none;
}
/*Create vertical spacing*/
li {
margin-bottom: 1px;
}
/*Make all menu links full width*/
ul li, li a {
width: 100%;
}
/*Display 'show menu' link*/
.show-menu {
display:block;
}
}
html generated:
<header>
<label for="show-menu" class="show-menu">Show Menu</label>
<input type="checkbox" id="show-menu" role="button">
<nav id="superior">
<ul id="menu-menu" class="menu nav nav-pills"> <li id="menu-item-18" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-18"><a href="http://127.0.0.1/wordpress/" aria-current="page">Inicio</a></li>
<li id="menu-item-130" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-130"><a href="http://127.0.0.1/wordpress/category/mejores-tal-cosa/">Mejores tal cosa</a>
<ul class="sub-menu">
<li id="menu-item-132" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-has-children menu-item-132"><a href="http://127.0.0.1/wordpress/que-es-lorem-ipsum/">Que es Lorem Ipsum?</a>
<ul class="sub-menu">
<li id="menu-item-131" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-131"><a href="http://127.0.0.1/wordpress/category/destacados/">Destacados</a></li>
</ul>
</li>
</ul>
</li>
<li id="menu-item-19" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-19"><a href="http://127.0.0.1/wordpress/pagina-ejemplo/">Página de ejemplo</a></li>
<li id="menu-item-24" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-24"><a href="http://127.0.0.1/wordpress/contacto/">Contacto</a></li>
</ul> </nav>
</header>
I changed the .hidden classes to .sub-menu and it's working. Not sure if it's the exact functionality you're looking for:
changed:
ul li a:hover + .hidden, .hidden:hover {
display: block;
}
to:
ul li a:hover + .sub-menu, .sub-menu:hover {
display: block;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.