Responsive Menu style using CSS Display the dropdown on hover

时间:2016-02-12 20:47:00

标签: css menu hover dropdown

So I have looked at lots of other examples and I still can't figure out what I am missing. The menu works great except when I look at it in phone mode the menu does not drop on the hover. Can you help?

THE CSS code

proxy.x = 12

THE HTML code

/*Strip the ul of padding and list styling*/
#menu ul {
    list-style: none;
    width: 100%;
    margin: 0;
    padding: 0;
    float: left;
    background: #645565;
    font-size: 1em;
}
/*Create a horizontal list with spacing*/
#menu li {
    float: left;
    position: relative;
    display: inline-block;
}
/*Style for menu link*/
#menu li a {
    display: block;
    line-height: 3em;
    font-family: Trebuchet MS, Verdana, Arial, sans-serif;
    font-size:  0.95em;
    color: #BFA877;
    text-decoration: none;
    padding: 0 0.9em;
}
/*Hover over text upper*/
#menu li:hover > a {
    color: #FFF6D6;
}
/*Displays dropdown*/
#menu ul li:hover > ul {
    display: block;
}
/*Hide dropdown links until they are needed*/
#menu li ul {
    display: none;
    position: absolute;
}
/*Display the dropdown on hover*/
.dropdown:hover .dropdown-content {
    display: block;
}

/*Style "show menu' label button and hide it by default*/
.dropdown{
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    text-decoration: none;
    color: #FFF6D6;
    background: #645565;
    text-align: center;
    padding: 10px 0;
    display: none;
    z-index: 1;
}
/*Hide checkbox*/
input[type=checkbox] {
    display: none;
}
/*Show menu when invisible checkbox is checked*/
input[type=checkbox]:checked ~ #menu {
    display: block;
}

/*==========MOBILE===========*/ 
    /*Responsive Styles*/
@media screen and (max-width: 768px){

/*Make dropdown links appear inline*/
    #menu ul {
        position: static;
        display: none;
    }
    /*Create vertical spacing*/
    #menu li {
        margin-bottom: 1px;
    }
    /*Make all menu links full width*/
    #menu ul li, li a {
        width: 100%;
    }
    /*Display "show menu" link*/
    .dropdown {
        display: block;
    }

}

1 个答案:

答案 0 :(得分:0)

Phones don't support the hover action!