CSS下拉列表悬停鼠标不起作用

时间:2013-09-04 09:19:07

标签: html css css3 drop-down-menu mouseover

我有一个代码HTML CODE:

<div class="wrapper-demo">

 <div id="dd" class="wrapper-dropdown-2" tabindex="1">Sign in with
                    <ul class="dropdown">
                        <li><a href="#"><i class="icon-twitter icon-large"></i>Twitter</a></li>
                        <li><a href="#"><i class="icon-github icon-large"></i>Github</a></li>
                        <li><a href="#"><i class="icon-facebook icon-large"></i>Facebook</a></li>
                    </ul>
                </div>
            </div>

AND CSS:

.wrapper-dropdown-2 {
position: relative; 
width: 200px;
margin: 0 auto;
padding: 10px 15px;

background: #fff;
border-left: 5px solid orange;
cursor: pointer;
text-align: left;
cursor: pointer;
outline: none;

}

.wrapper-dropdown-2:after {
    content: "";
    width: 0;
    height: 0;
    position: absolute;
    right: 16px;
    top: 50%;
    margin-top: -3px;
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: grey transparent;

}
.dropdown {
    display:none;
}
.wrapper-dropdown-2:hover ul.dropdown  {
    position: absolute;
    display:block;
    top: 100%;
    left: -5px;
    right: 0px;
    background: white;
    -webkit-transition: all 0.3s ease-out;
    -moz-transition: all 0.3s ease-out;
    -ms-transition: all 0.3s ease-out;
    -o-transition: all 0.3s ease-out;
    transition: all 0.3s ease-out;
    list-style: none;
    opacity: 0;
    pointer-events: none;
}
.wrapper-dropdown-2 .dropdown li a {
    display: block;
    text-decoration: none;
    color: #333;
    border-left: 5px solid;
    padding: 10px;
    -webkit-transition: all 0.3s ease-out;
    -moz-transition: all 0.3s ease-out;
    -ms-transition: all 0.3s ease-out;
    -o-transition: all 0.3s ease-out;
    transition: all 0.3s ease-out;
}

http://jsfiddle.net/pvt3e/

我试着将鼠标悬停在:登录,打开下拉菜单但不起作用! 我不能与js合作。因为我有1.8.2的问题,但我认为我们可以找到一个CSS

的解决方案

4 个答案:

答案 0 :(得分:2)

试试这个

.wrapper-dropdown-2:hover ul{
    display:block;  
}

updated jsFiddle File

同时删除.dropdown:悬停你的风格

答案 1 :(得分:1)

您将丢失添加悬停代码,以便在悬停时看到下拉列表。添加css悬停。

.wrapper-dropdown-2:hover .dropdown
{
    display:block;
}

Live Demo

答案 2 :(得分:0)

您需要初始化您的javascript以及链接到jquery。我看到你正在使用Codrops的下拉列表,为什么不下载源代码?

答案 3 :(得分:0)

只需替换您的CSS

.dropdown:hover  {
  /* Size & position */
    position: absolute;
    display:block;
    top: 100%;
    left: -5px;
    right: 0px;

    /* Styles */
    background: white;
    -webkit-transition: all 0.3s ease-out;
    -moz-transition: all 0.3s ease-out;
    -ms-transition: all 0.3s ease-out;
    -o-transition: all 0.3s ease-out;
    transition: all 0.3s ease-out;
    list-style: none;

    /* Hiding */
    opacity: 0;
    pointer-events: none;
}

到我的CSS并获得结果

.wrapper-dropdown-2:hover > .dropdown  {
   position: absolute;
    display:block;
    left: -45px;
       background: white;
      top:24px;
 }